Microsoft KB Archive/102576

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 20:57, 16 July 2020 by X010 (talk | contribs) (1 revision imported: importing part 2)

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

Q102576



The information in this article applies to:


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





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
   } 

Additional query words: 3.10 3.50 4.00

Keywords :
Issue type : kbprb
Technology : kbAudDeveloper kbSDKSearch kbWin32sSearch kbWin32API kbWinSDKSearch


Last Reviewed: December 16, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.