Creating a Hidden MDI Child Window

ID Number: Q70080

3.00

WINDOWS

Summary:

Whenever Windows version 3.0 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. This information applies to

applications created with the Windows Software Development Kit (SDK)

version 3.0.

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 we 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 );

...

For more information on the Windows 3.0 MDI, query on the following

words:

prod(winsdk) and MDI