If you create a sample MDI application using the MDI wizard the status bar does not get resized on changing the size of the main window. There is code in the WM_SIZE message but it appears that the initial setting of the global HWND for the status bar is incorrect. If you add a new line at the end of the handler for WM_CREATE like g_hWndStatusBar = GetDlgItem(hwnd, ID_STATUSBAR); it will work correctly. I am not sure why the initial setting of this hwnd in WM_CREATE is not working, any ideas?
I've looked at it - it appears that if you use max speed compile it has a problem, if you select no speed optimization it works.
I will get back later.
EDIT:
I think there was a buffer overrun with ptArray
void SizeStatusPanels(HWND hWndParent, HWND hWndStatusbar, int nrOfParts)
{
int ptArray[nrOfParts];
Change to
void SizeStatusPanels(HWND hWndParent, HWND hWndStatusbar, int nrOfParts)
{
int ptArray[nrOfParts+1];
I have updated the wizard on my web site.
Thanks for the bug report.
John
Few ideas after testing that in Linux/Wine:
In HWND CreateToolBarWnd(HWND hWndParent, HINSTANCE hInst)
WS_EX_CLIENTEDGE -> 0
remove | WS_BORDER
// Create the toolbar.
hWndTB = CreateWindowEx(0,
TOOLBARCLASSNAME,
(LPTSTR) NULL,
WS_CHILD | CCS_TOP | TBSTYLE_TOOLTIPS,
0, 0, 0, 0,
hWndParent,
(HMENU) ID_TOOLBAR,
hInst,
NULL);
Just another way to do that:
LRESULT FrameWndProc_OnSize(HWND hwnd, int flag, int x, int y)
{
// ReSize the various child windows
SendMessage(g_hWndStatusBar, WM_SIZE, flag, x);
SendMessage(g_hWndToolBar, WM_SIZE, flag, x);
SizeStatusPanels(hwnd, g_hWndStatusBar, numParts);
// Position the MDI client window between the tool and status bars
if (flag != SIZE_MINIMIZED)
{
RECT rcStat, rcClient;
GetClientRect(hwnd, &rcClient);
GetClientRect(g_hWndToolBar, &rcStat);
rcClient.top = rcStat.bottom + 3;
rcClient.bottom = rcClient.bottom - rcStat.bottom - 3;
GetClientRect(g_hWndStatusBar, &rcStat);
rcClient.bottom = rcClient.bottom - rcStat.bottom;
MoveWindow(g_hWndClient, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, TRUE);
}
return 0;
}
Thanks, I will make that change to the call to MoveWindow.
John