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



The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) 3.1
  • Microsoft Win32 Application Programming Interface (API), when used with:
    • Microsoft Windows NT Server 3.5
    • Microsoft Windows NT Server 3.51
    • Microsoft Windows NT Workstation 3.5
    • Microsoft Windows NT Workstation 3.51
    • Microsoft Windows 95

This article was previously published under Q102576

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. 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.

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
   }
				

Modification Type:MinorLast Reviewed:3/7/2005
Keywords:kbprb KB102576