⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotkeys.cpp

📁 一个WinCE6。0下的IP phone的源代码
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include "HotKeys.hpp"
#include "Common.hpp"
#include "NewResource.hpp"


const HotKeys_t::HotKeysRCData_t*   HotKeys_t::sc_pHotKeys      = NULL;
const unsigned int                  HotKeys_t::sc_HotkeyIdBase  = 0xcc; 


HRESULT
HotKeys_t::InitializeRCData(
    void
    )
{
    HotKeys_t::HotKeysRCData_t* pHotKeys;

    HRESULT hr = CommonUtilities_t::InitializeRCDataHelper(
        IDR_HOTKEYS_DATA,
        sizeof(HotKeys_t::HotKeysRCData_t),
        reinterpret_cast<void**>(&pHotKeys)
        );

    sc_pHotKeys = pHotKeys;
    return hr;
}

UINT
HotKeys_t::GetHotKey(
    HotKeyId_e vkHotKey
    )
{
    if (sc_pHotKeys && (vkHotKey < LastHotKey))
    {
        return sc_pHotKeys->m_VirtualKeys[vkHotKey];
    }

    //if we don't get it from resource file, use the default value
    switch (vkHotKey)
    {
    case vkVoicemail:
        return VK_ESCAPE;

    case vkHold:
        return VK_F8;

    case vkRedial:
        return VK_F10; 
        
    case vkTransfer:
        return VK_F9; 
        
    case vkMute:
        return VK_F7; 
        
    case vkHookSwitch:
        return VK_F5; 
        
    case vkSpeaker: 
        return VK_F6; 
        
    default:
        ASSERT(0);
        return 0;
    }
}


HotKeys_t::HotKeyId_e
HotKeys_t::GetHotKeyName(
    UINT HotKeyId
    )
{
    if (HotKeyId < sc_HotkeyIdBase || HotKeyId >= sc_HotkeyIdBase + LastHotKey)
    {
        return LastHotKey; 
    }

    return static_cast<HotKeyId_e>(HotKeyId - sc_HotkeyIdBase); 
}



HRESULT
HotKeys_t::RegisterHotKeys(
    HWND Owner
    )
{
    HRESULT hr;

    hr = InitializeRCData();
    if (FAILED(hr))
    {
        return hr;
    }

    //Loop through the hotkeys and register them with the system    
    int Index;
    for (Index = 0; Index < _countof(sc_pHotKeys->m_VirtualKeys); Index++)
    {
        if (
            !RegisterHotKey(
                Owner, 
                (sc_HotkeyIdBase + Index),
                MOD_KEYUP,                          //register they keys as keyup
                sc_pHotKeys->m_VirtualKeys[Index]
                )
            )
        {
            return CommonUtilities_t::GetErrorFromWin32();
        }
    }

    return S_OK;
}

HRESULT
HotKeys_t::UnRegisterHotKeys(
    HWND Owner
    )
{
    if (!sc_pHotKeys)
    {
        return S_FALSE;
    }

    //Loop through the hotkeys and register them with the system    
    int Index;
    for (Index = 0; Index < _countof(sc_pHotKeys->m_VirtualKeys); Index++)
    {
        if (!UnregisterHotKey(Owner, (sc_HotkeyIdBase + Index)))
        {
            return CommonUtilities_t::GetErrorFromWin32();
        }
    }

    return S_OK;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -