Hi,
I have a problem enabling and disabling certain parts of a menu.
When my MDI Child windows are minimized or not maximized the menu works correctly.
But if they are maximized the menu fails to be changed.
Any ideas as to what could be wrong?
This is a discussion on MDI and MENU Problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I have a problem enabling and disabling certain parts of a menu. When my MDI Child windows are minimized ...
Hi,
I have a problem enabling and disabling certain parts of a menu.
When my MDI Child windows are minimized or not maximized the menu works correctly.
But if they are maximized the menu fails to be changed.
Any ideas as to what could be wrong?
Ok, i have sorted out that problem but now i have another..
The code above is my MDI CHILD Callback.Code:LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: { HFONT hfDefault; HWND hEdit; hEdit = CreateWindowEx(0, "RICHEDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_DISABLENOSCROLL | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL); hfDefault = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); } break; case WM_MDIACTIVATE: { HMENU hMenu, hFileMenu; UINT EnableFlag; hMenu = GetMenu(g_hMainWindow); if(hwnd == (HWND)lParam) { EnableFlag = MF_ENABLED; } else { EnableFlag = MF_GRAYED; } EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag); EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag); hFileMenu = GetSubMenu(hMenu, 0); EnableMenuItem(hFileMenu, IDM_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag); EnableMenuItem(hFileMenu, IDM_FILE_CLOSE, MF_BYCOMMAND | EnableFlag); EnableMenuItem(hFileMenu, IDM_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag); DrawMenuBar(g_hMainWindow); } break; case WM_CLOSE: { DestroyWindow(hwnd); } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDM_EDIT_CUT: { SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0); } break; case IDM_EDIT_COPY: { SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0); } break; case IDM_EDIT_PASTE: { SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0); } break; } } break; case WM_SIZE: { HWND hEdit; RECT rcClient; GetClientRect(hwnd, &rcClient); hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT); SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER); } return DefMDIChildProc(hwnd, msg, wParam, lParam); default: return DefMDIChildProc(hwnd, msg, wParam, lParam); } return 0; }
When i close one of the MDI Child windows, the window closes but the minimize, maximize and close buttons remain along the menu bar. The more windows that get closed the more the buttons mount along the Menu bar.
Is this the correct way to close the child windows?
DefMDIChildProc may do this if given the chance.An application sends the WM_MDIDESTROY message to a MDI client window to close an MDI child window.
Thanks for the help anonytmouse.
That was exactly what i was missing!