PRB: Property Sheet w/ Multiline Edit Control Ignores ESC Key

Last reviewed: September 29, 1995
Article ID: Q130765
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

SYMPTOMS

Pressing the ESC key when the focus is on a Multiline Edit control that is a child of a property sheet page, does not dismiss the property sheet control as expected.

CAUSE

When the ESC key is pressed while focus is on a Mutiline Edit control, the IDCANCEL notification (sent with a WM_COMMAND message) is sent to the property sheet dialog proc whose template contains the Multiline Edit control. Property sheet dialog procs do not process this message, so it is not forwarded to the property sheet control.

RESOLUTION

Trap the IDCANCEL notification that is sent along with the WM_COMMAND message in the property sheet dialog proc that contains the multiline edit control. Then forward the message to the property sheet control. (The property sheet control is the parent of all the property sheet page dialogs.) The following code shows how to do this:

Code Sample

//
//  FUNCTION: SheetDialogProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for a page in the PPT sheet control.
//
//  PARAMETERS:
//    hdlg - window handle of the property sheet
//    wMessage - type of message
//    wparam - message-specific information
//    lparam - message-specific information
//
//  RETURN VALUE:
//    TRUE -  message handled
//    FALSE - message not handled
//

LRESULT CALLBACK SheetDialogProc(HWND hdlg,
                      UINT uMessage,
                     WPARAM wparam,
                     LPARAM lparam)
{
    LPNMHDR lpnmhdr;
    HWND    hwndPropSheet;
    switch (uMessage)
    {
   case WM_INITDIALOG:

      // Do whatever initializations you have here.
      return TRUE;


   case WM_NOTIFY:

      // more code here ...

      break;


    case WM_COMMAND:

       switch(LOWORD(wparam))
      {

         case IDCANCEL:

         // Forward this message to the parent window
         // so that the PPT sheet is dismissed
            SendMessage(GetParent(hdlg),
                          uMessage,
                          wparam,
                          lparam);
         beak;

         default:
         break;
      }
      break;

   }

NOTE: This solution also works with wizard controls. This behavior is seen under both Windows NT and Windows 95; the solution in this article works for both platforms.


Additional reference words: 4.00 user styles
KBCategory: kbui kbprb kbcode
KBSubcategory: UsrCtl


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: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.