HOWTO: Create a Hidden MDI Child Window

ID: Q70080


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK)
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows 2000


SUMMARY

Whenever Windows creates a new multiple-document interface (MDI) child window in response to a WM_MDICREATE message, it makes that child window visible.

The information below describes how to create a hidden MDI child window without causing an unattractive "flash" on the screen as the window is created visible and then hidden.


MORE INFORMATION

A code fragment such as the following can be used to create an invisible MDI child:


   MDICREATESTRUCT mcs;            // Structure to pass with WM_MDICREATE.
   HWND            hWndMDIClient;  // The MDI client window.
   HWND            hwnd;           // Temporary window handle.

         ...
   // Assume that you have already filled out the MDICREATESTRUCT.

   // Turn off redrawing in the MDI client window.
   SendMessage(hwndMDIClient, WM_SETREDRAW, FALSE, 0L);

   /*
    * Create the MDI child. It will be created visible, but will not
    * be seen because redrawing to the MDI client has been disabled.
   */ 
   hwnd = (WORD)SendMessage(hwndMDIClient,
                            WM_MDICREATE,
                            0,
                            (LONG)(LPMDICREATESTRUCT)&mcs);

   // Hide the child.
   ShowWindow(hwnd, SW_HIDE);

   // Turn redrawing in the MDI client back on,
   // and force an immediate update.
   SendMessage(hwndMDIClient, WM_SETREDRAW, TRUE, 0L);
   InvalidateRect( hwndMDIClient, NULL, TRUE );
   UpdateWindow( hwndMDIClient );
         ... 

Additional query words:

Keywords : kbMDI kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS kbWndw
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 28, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.