I have an Win32 C++ MDI form with a toolbar at the top, a statusbar at the bottom and an edit control sitting on top of the statusbar, with the rest of the client area clear for child windows.
Here's the code to create the edit control:
HFONT hfDefault;
HWND hEdit;
TCHAR lpszSometext[] = L"This is the first line in this edit control "
L"This is the second line in this edit control "
L"This is the third line in this edit control ";
hEdit = CreateWindowEx(
WS_EX_CLIENTEDGE, L"EDIT",
NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0,
hWnd,
(HMENU)IDC_MAIN_EDIT,
GetModuleHandle(NULL),
NULL);
if (hEdit == NULL)
MessageBox(hWnd, L"Could not create edit control.", L"Error", MB_OK | MB_ICONERROR);
SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)lpszSometext);
hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
And this is the code to resize the toolbar, statusbar and edit control in WM_SIZE of the main window callback;
HWND hToolbar, hStatusbar, hEdit, hMDI;
RECT rcToolbar, rcStatusbar, rcClient;
int iToolbarHeight, iStatusbarHeight, iEditHeight, iMDIHeight;
iEditHeight = 60;
hToolbar = GetDlgItem(hWnd, IDC_MAIN_TOOL);
SendMessage(hToolbar, TB_AUTOSIZE, 0, 0);
hStatusbar = GetDlgItem(hWnd, IDC_MAIN_STATUS);
SendMessage(hStatusbar, WM_SIZE, 0, 0);
GetWindowRect(hToolbar, &rcToolbar);
iToolbarHeight = rcToolbar.bottom - rcToolbar.top;
GetWindowRect(hStatusbar, &rcStatusbar);
iStatusbarHeight = rcStatusbar.bottom - rcStatusbar.top;
GetClientRect(hWnd, &rcClient);
iMDIHeight = rcClient.bottom - iToolbarHeight - iStatusbarHeight - iEditHeight;
hEdit = GetDlgItem(hWnd, IDC_MAIN_EDIT);
SetWindowPos(hEdit, NULL, 0, rcClient.bottom - iStatusbarHeight - iEditHeight, rcClient.right, rcClient.bottom - iStatusbarHeight, SWP_NOZORDER);
hMDI = GetDlgItem(hWnd, IDC_MAIN_MDI);
SetWindowPos(hMDI, NULL, 0, iToolbarHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
All three controls are created the same way with CreateWindowEx(), however the text placed in the edit control at creation is a no-show and the edit control makes hideous artifacts on the MDI clint window whenever the main form is resized, as if the edit control is trying to snap to the bottom of the toolbar.
What I have tried:
I have't tried anything yet, I can't think of anywhere to go other than different method of control creation.