次の方法で共有


TranslateAccelerator method

Called by MSHTML when IOleInPlaceActiveObject::TranslateAccelerator or IOleControlSite::TranslateAccelerator is called.

Syntax

HRESULT retVal = object.TranslateAccelerator(lpMsg, pguidCmdGroup, nCmdID);

Parameters

  • lpMsg [in]
    Type: LPMSG

    A pointer to a MSG structure that specifies the message to be translated.

  • pguidCmdGroup [in]
    Type: const GUID

    A pointer to a GUID for the command group identifier.

  • nCmdID [in]
    Type: DWORD

    A DWORD that specifies a command identifier.

Return value

Type: HRESULT

This method can return one of these values.

Return code Description
S_OK

The message was handled. Prevent the host default behavior.

S_FALSE

The message was not handled. Host default behavior is allowed.

 

Examples

When you use accelerator keys, such as TAB, you might want to override the default host behavior. This example shows how to disable the default tabbing behavior of the host. The code returns S_OK to indicate that the message was handled.

CYourControlSite::TranslateAccelerator(MSG *pMsg, DWORD dwFlags)
{
    HRESULT hr = S_FALSE;
    
    if (pMsg && pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB) {
        // The message was handled.
        hr = S_OK;
    }
    return hr;
}