Ok. I am making a program. I need to know how to resize a multi-line edit box to fit the program window when it's resized. Also, how would I add text to the edit box? Is it SetDlgItemText?
Ok. I am making a program. I need to know how to resize a multi-line edit box to fit the program window when it's resized. Also, how would I add text to the edit box? Is it SetDlgItemText?
I need to do it only when the user click Insert -> Text. How do I do that. I tried SetDlgItemText(); but it don't work.
I have:
case WM_CREATE:
hMenu = CreateMenu();
hSubMenu = CreatePopupMenu();
AppendMenu(hSubMenu, MF_STRING, CM_FILE_NEW, "&New");
AppendMenu(hMenu, MF_STRING + MF_POPUP, (UINT)hSubMenu, "&File");
hSubMenu = CreatePopupMenu();
AppendMenu(hSubMenu, MF_STRING, CM_INSERT_LINK, "&Link");
AppendMenu(hMenu, MF_STRING + MF_POPUP, (UINT)hSubMenu, "&Insert");
SetMenu(hwnd, hMenu);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case CM_FILE_NEW:
HWND html;
html = CreateWindowEx(
WS_EX_STATICEDGE | WS_EX_CLIENTEDGE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
"EDIT",
"",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL,
0, 0,
540, 330 ,
hwnd,
(HMENU) 1,
hInst,
NULL
);
break;
case CM_INSERT_LINK:
SetDlgItemText(html, 0, "<a href=""> </a>");
break;
}
break;
Ok. Now I used:
#define IDC_NSRT 1001 at the top.
And:
html = CreateWindowEx(
WS_EX_STATICEDGE | WS_EX_CLIENTEDGE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
"EDIT",
"",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL,
0, 0,
540, 330 ,
hwnd,
(HMENU) 1,
hInst,
NULL
);
break;
case CM_INSERT_LINK:
SetDlgItemText(html, IDC_NSRT, "<a href=""> </a>");
break;
Wouldn't html be the handle? I used HWND html; before it.
When I use:
SetDlgItemText((HDLG)html, 0, "<a href=""> </a>");
I get:
HDLG undeclared
Nothing even happens when I do that.
Well, an HTML page maker, actually. You can edit the HTML and save it or if you need shortcuts, that is what my Insert menu is for.
Change your CreateWindowEx to :
SetDlgItemText() wants a handle to the parent window and an ID of the child window. You can either use the handle to your edit window -Code:html = CreateWindowEx( WS_EX_STATICEDGE | WS_EX_CLIENTEDGE , "edit", "", WS_CHILD|WS_VISIBLE|ES_MULTILINE|WS_VSCROLL|WS_HSCROLL|ES_LEFT|ES_AUTOHSCROLL| ES_AUTOVSCROLL, 0, 0, 540, 330 , hWnd, (HMENU) 1, hInst, NULL );
or use your parent handle -Code:SetWindowText(html,"<a href=""> </a>");
You've defined IDC_NSRT as 1001 but given your edit child window an ID of 1 in your CreateWindowEx() call, so if you want to use IDC_NSRT you'll have to change one of the values.Code:SetDlgItemText(hWnd, 1,"<a href=""> </a>" );
zen
That still doesn't work.
that last reply did it! Thank you for helping me!
I am assuming this is in a callback function. You may need to set the HWND to a static. Many messages pass thru the callback and it will have lost the value before the next msg is processed.
Try GetActiveWindow() as this will return the HWND of the dlg with the focus.
Test that the Edit has been created ie html!=NULL or can see it on screen. Use GetLastError() if not.
Ensure you are setting the ID (IDC_NSRT) as the HMENU param in the CreateWindowEx, ie
(HMENU)IDC_NSRT
Read the help for this.
Next time look at the second page!!