PRB: Setting the Focus to the Active MDI Child Window

ID Number: Q69807

3.00

WINDOWS

buglist3.00 fixlist3.10

Summary:

SYMPTOMS

When the CTRL+F6 key combination is used to move from an icon MDI

child window to a non-iconic MDI child window, the input focus

remains on the MDI client window.

RESOLUTION

Microsoft has confirmed this to be a problem in Windows version

3.0. To work around this problem, you can add code to the window

procedure for the MDI child window. The code verifies that when a

non-iconic MDI child window becomes active, it correctly receives

the input focus. See below for an example of the appropriate code.

This problem was corrected in Windows version 3.1.

More Information:

In the code below, "hwnd" has been passed as the hWnd parameter of the

WM_MDIACTIVATE message:

// if (This window is now the active MDI child

// && this window is not an icon)

// {

// grab the input focus

// }

case WM_MDIACTIVATE:

if ((TRUE == wParam) && (!IsIconic(hwnd)))

{

SetFocus(hwnd);

return TRUE;

}

else

break; // For example, return DefMDIChildProc

Note that in many MDI applications, the focus could be set to an

appropriate child of the MDI child, rather than to the MDI child

itself. For example, a text editing program such as MULTIPAD would set

the focus to its child edit control.

Additional reference words: 3.00