SAMPLE: Customizing the MDI Window Menu

Last reviewed: February 15, 1996
Article ID: Q99803
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

The MDIWINMN sample in the Microsoft Software Library demonstrates how to customize the Window menu of a multiple document interface (MDI) frame window. MDIWINMN shows how to limit the number of listed MDI children in the Window menu to any number and how to bring up a customized dialog box when the More Windows menu item is selected. This sample also shows how to list all the MDI children in the Window menu without using a More Windows menu item.

Download MDIWINMN.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download MDIWINMN.EXE (size: 26251 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get MDIWINMN.EXE (size: 26251 bytes) 
    

MORE INFORMATION

To compile, type NMAKE to build the sample; this sample limits the number of MDI child windows listed in the Window menu and brings up the customized dialog box when the More Windows menu item is selected. Type NMAKE MENU=NOLIMIT to build the sample that lists all the the MDI children in the Window menu without using a More Windows menu item.

The following code changes must be made in the window procedure of the MDI frame window to customize the Window menu:

  1. Specify NULL as the Window menu handle when creating the MDI client, because the application handles all the processing of the Window menu:

          CLIENTCREATESTRUCT ccs;
          ccs.hWindowMenu  = NULL;
          ccs.idFirstChild = IDM_FIRSTCHILD;
    

  2. Update the Window menu using ChangeWindowMenu() when the frame window receives WM_INITMENUPOPUP. ChangeWindowMenu() is implemented in the sample code:

         case WM_INITMENUPOPUP:
    
              if ((HMENU)wParam == hMenuWindow)
                 ChangeWindowMenu(hMenuWindow);
              break;
    
    

  3. Call ProcessWindowMenu() in the default processing of WM_COMMAND received by the frame window. ProcessWindowMenu() is implemented in the sample code:

         case WM_COMMAND:
          {
    
              switch (wParam)
              {
                  :
                  :
               default:
                  if (ProcessWindowMenu(wParam))
                        return 0L;
                  else return DefFrameProc(hwnd, g_hwndMDIClient,
                                          msg, wParam, lParam);
               }
          }
    
    
ChangeWindowMenu() removes the old listing of MDI children from the Window menu. It then enumerates the MDI child windows and adds their names to the Window menu so the Window menu reflects the current state when shown.

ProcessWindowMenu() processes WM_COMMAND messages that result from menu selections of MDI children in the Window menu. It also brings up a customized dialog box when the More Windows menu item is selected.


Additional reference words: 3.00 3.10 softlib MDIWINMN.EXE
KBCategory: kbprg kbfile
KBSubcategory: UsrMdi


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.