Modifying the System Menu of an MDI Child WindowLast reviewed: August 12, 1997Article ID: Q77930  | 
	
| 
	
 
 The information in this article applies to: 
 
 SUMMARYThe system menu of an MDI child can be modified only after the WM_CREATE message for the MDI child is processed. If an application tries to modify the system menu of an MDI child during the processing of the child's WM_CREATE message, the system menu will not be changed. 
 MORE INFORMATIONIt is common to try to alter a window's system menu during the processing of its WM_CREATE message. This method has no effect on the system menu of an MDI child, however, because of the way a MDI child window is created: 
 To work around this design decision, the child window procedure can post a custom message to itself during the processing of its WM_CREATE message. This custom message is processed after the MDI client has finished creating the MDI child. The code for this workaround might resemble the following: 
 #define WM_ADDMENUITEM (WM_USER+1)LONG FAR PASCAL MDIChildWndProc(HWND hWnd,                                 WORD wMsg,
                                WORD wParam,
                                LONG lParam)
{
    switch (wMsg)
       {
    case WM_CREATE:
       PostMessage(hWnd, WM_ADDMENUITEM, 0, 0L);
       break;
    case WM_ADDMENUITEM:
       {
       HMENU        hMenu;
       hMenu = GetSystemMenu(hWnd, FALSE);
       InsertMenu(hMenu, -1, MF_BYPOSITION, IDM_NEW,
             (LPSTR)"New Item\0");
       DrawMenuBar(hWnd);
       }
       break;
    default:
       return DefMDIChildProc(hWnd, wMsg, wParam, lParam);
       }
    return 0;
}
 Keywords : kb16bitonly UsrMdi kbhowto Version : 3.0 3.1 Platform : WINDOWS Issue type : kbhowto  | 
	
	================================================================================ 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.  |