PRB: DDEML Fails to Call TranslateMessage() in its Modal Loop

Last reviewed: November 2, 1995
Article ID: Q102576
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
    

SUMMARY

During a synchronous transaction, DDEML causes the client to enter a modal loop until the transaction is processed. While DDEML dispatches messages appropriately, it fails to call TranslateMessage() while inside this modal loop. This problem does not apply to asynchronous transactions, where no such modal loop is entered.

SYMPTOMS

A common symptom of this problem is seen as the client processes user input while inside DDEML's modal loop in a synchronous transaction. WM_KEYDOWN and WM_KEYUP messages are received, with no corresponding WM_CHAR message for the typed character.

CAUSE

No WM_CHAR message is received because the WM_KEYDOWN message is never translated. For this to take place, a call to TranslateMessage() must be made inside the modal loop.

RESOLUTION

This limitation is by design. DDEML applications can work around this limitation by installing a WH_MSGFILTER hook, watching out for code == MSGF_DDEMGR.

The WH_MSGFILTER hook allows an application to filter messages while the system enters a modal loop, such as when a modal dialog box (code == MSGF_DIALOGBOX) or a menu (code == MSGF_MENU) is displayed; and similarly, when DDEML enters a modal loop in a synchronous transaction (code == MSGF_DDEMGR).

The Windows 3.1 Software Development Kit (SDK) DDEML\CLIENT sample demonstrates how to do this in DDEML.C's MyMsgFilterProc() function:

/**********************************************************************
 *
 *  FUNCTION: MyMsgFilterProc
 *
 *  PURPOSE:  This filter proc gets called for each message we handle.
 *            This allows our application to properly dispatch messages
 *            that we might not otherwise see because of DDEMLs modal
 *            loop that is used while processing synchronous transactions.
 *
***********************************************************************/

   DWORD FAR PASCAL MyMsgFilterProc( int nCode, WORD wParam,

                DWORD lParam)
   {
       wParam; // not used

    #define lpmsg ((LPMSG)lParam)

    if (nCode == MSGF_DDEMGR) {

           /* If a keyboard message is for the MDI, let the MDI client
            * take care of it. Otherwise, check to see if it's a normal
            * accelerator key. Otherwise, just handle the message as usual.
            */

           if ( !TranslateMDISysAccel (hwndMDIClient, lpmsg) &&
                !TranslateAccelerator (hwndFrame, hAccel, lpmsg)){
               TranslateMessage (lpmsg);
               DispatchMessage (lpmsg);
           }
           return(1);
       }
       return(0);
   #undef lpmsg
   }


Additional reference words: 3.10 3.50 3.51 4.00 95
KBCategory: kbui kbprb kbcode
KBSubcategory: UsrDde


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.