PRB: Menu Mnemonics Not Working During In-Place Activation

Last reviewed: May 17, 1995
Article ID: Q104460
The information in this article applies to:
  • Microsoft OLE Libraries for Windows and Win32s, version 2.0
  • Microsoft OLE Libraries, included with:

        - Microsoft Windows NT, versions 3.5 and 3.51
        - Microsoft Windows 95
    

SYMPTOMS

The menu mnemonics for an object do not operate properly, causing the system to hang.

CAUSE

The server application is not calling OleTranslateAccelerator inside of its message loop.

RESOLUTION

For menu commands to be dispatched properly during in-place editing, OLE 2.0 needs to have the server application call OleTranslateAccelerator, even if the server application does not have accelerator support. This OLE application programming interface (API) does the needed translation of key messages, and ensures that the appropriate action occurs.

To be more efficient, a server application need only pass "keystroke" messages to OleTranslateAccelerator. The following code demonstrates what the message loop for an OLE server application should look like:

Sample Code

 // Message loop for an OLE server.
 //
 while (GetMessage(&msg, NULL, NULL))
    {
    if (m_fInplaceActive)  // If currently active in place.
        if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST)
            // If it is a "keystroke" message.
            if (OleTranslateAccelerator(...) == NOERROR)
                continue; // OLE handled the message

    TranslateMessage(...);
    DispatchMessage(...);
    }

MORE INFORMATION

When the object's server is a stand-alone .EXE and the in-place active object gets a keystroke message that is not a recognized accelerator, the object must check to see if the message is one that the container recognizes by calling the OleTranslateAccelerator function. If the container does not want the keystroke, then the OleTranslateAccelerator function will return FALSE. In this case, the object should continue using its normal TranslateMessage and DispatchMessage code.

If the container accepts the keystroke, OLE will call the container's IOleInPlaceFrame::TranslateAccelerator member function to translate the message. The container may call the Windows TranslateAccelerator and/or TranslateMDISysAccel functions to process the accelerator key, or do its own special processing.


Additional reference words: 2.00 3.50 4.00
KBCategory: kbole kbprg kbprb
KBSubcategory: LeTwoInp


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