📄 hotkeys.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 "resource.h"
const HotKeys_t::HotKeysRCData_t* HotKeys_t::s_pHotKeys = NULL;
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)
);
s_pHotKeys = pHotKeys;
return hr;
}
UINT
HotKeys_t::GetHotKey(
HotKeyId_e vkHotKey
)
{
if (s_pHotKeys && (vkHotKey < LastHotKey))
{
return s_pHotKeys->m_VirtualKeys[vkHotKey];
}
switch (vkHotKey)
{
case vkHome:
return VK_HOME;
case vkMenu:
return VK_END;
case vkButton1:
case vkButton2:
case vkButton3:
case vkButton4:
return VK_F1 + (vkHotKey - vkButton1);
case vkDirectory:
return VK_RETURN;
case vkSpeedDial:
return VK_TAB;
case vkVolumeUp:
return VK_PRIOR;
case vkVolumeDown:
return VK_NEXT;
case vkShutdown:
return VK_F12;
default:
ASSERT(0);
return 0;
}
}
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(s_pHotKeys->m_VirtualKeys); Index++)
{
if (
!RegisterHotKey(
Owner,
(vkHome + Index),
MOD_KEYUP, //register they keys as keyup
s_pHotKeys->m_VirtualKeys[Index]
)
)
{
return CommonUtilities_t::GetErrorFromWin32();
}
}
return S_OK;
}
HRESULT
HotKeys_t::UnRegisterHotKeys(
HWND Owner
)
{
if (!s_pHotKeys)
{
return S_FALSE;
}
//Loop through the hotkeys and register them with the system
int Index;
for (Index = 0; Index < _countof(s_pHotKeys->m_VirtualKeys); Index++)
{
if (!UnregisterHotKey(Owner, (vkHome + Index)))
{
return CommonUtilities_t::GetErrorFromWin32();
}
}
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -