PRB: Pressing the ENTER Key in an MDI Application

Last reviewed: November 2, 1995
Article ID: Q99799
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SYMPTOMS

In a standard Microsoft Windows version 3.1 multiple document interface (MDI) application, when a minimized MDI child is active and the user presses the ENTER key, the child is not restored.

This is inconsistent with other MDI applications, such as File Manager and Program Manager. An MDI child in one of these applications is restored when it is the active MDI child and the ENTER key is pressed. When a normal Windows-based application is minimized and the user presses ENTER, that application is restored to a normal state.

RESOLUTION

One quick workaround to this problem is to create an accelerator for the ENTER key and restore the minimized MDI child when the key is pressed.

MORE INFORMATION

It may be desirable to implement the same restore feature that File Manager and Program Manager have implemented in order to enable the user to restore an MDI child by pressing the ENTER key. If this feature is implemented, then the MDI application can be consistent with other popular applications such as File Manager, Microsoft Excel, and Microsoft Word.

To achieve this effect in an MDI application, create an accelerator in the accelerator table of the resource file for the application. This can be done as follows:

MdiAccelTable ACCELERATORS

     {
     .  .  .
     .  .  .
     VK_RETURN, IDM_RESTORE, VIRTKEY
     }

After this accelerator has been installed in the MDI application, each time the ENTER key is pressed by the user, an IDM_RESTORE command will be sent to the MDI frame window's window procedure through a WM_COMMAND message. When the MDI frame receieves this message, its window procedure should retrieve a handle to the active MDI child and determine if it is minimized. If it is minimized, then it can restore the MDI child by sending the MDI client a WM_MDIRESTORE message. This can all be done with the following code:

        case IDM_RESTORE:
           {
           HWND hwndActive;

           hwndActive = SendMessage(hwndClient,WM_MDIGETACTIVE,0,0L);
           if (IsIconic(hwndActive))
              SendMessage(hwndClient,WM_MDIRESTORE,hwndActive,0L);
           break;
           }


Additional reference words: 3.10 3.50 3.51 4.00 95
KBCategory: kbui kbprb kbcode
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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.