blob: ad6144dc28ea905a46b7ed057a2a23ceb39d8eff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// HotKey.cpp: implementation of the CHotKey class.
//
//////////////////////////////////////////////////////////////////////
#include "gen_hotkeys.h"
#include "HotKey.h"
//////////////////////////////////////////////////////////////////////
// Registration / Unregstration
//////////////////////////////////////////////////////////////////////
int RegisterHotkey(HOTKEY *hk)
{
if (!hk) return 1;
wchar_t atomName[1024] = {0};
bool unicode = 0;
char* name = GetCommandName(hk->hkd.iCommand, &unicode);
StringCchPrintfW(atomName, 1024, (unicode?L"%s %X %X %X":L"%hs %X %X %X"), name, hk->hkd.dwHotKey, hk->hkd.iCommand, GetTickCount());
hk->atom = GlobalAddAtomW(atomName);
if (!hk->atom)
return 1;
return !RegisterHotKey(psPlugin.hwndParent, hk->atom, GetModKeys(hk->hkd.dwHotKey), LOBYTE(hk->hkd.dwHotKey));
}
void UnregisterHotkey(HOTKEY *hk)
{
if (!hk || !hk->atom)
return;
UnregisterHotKey(psPlugin.hwndParent, hk->atom);
GlobalDeleteAtom(hk->atom);
hk->atom = NULL;
}
//////////////////////////////////////////////////////////////////////
// Set / Get
//////////////////////////////////////////////////////////////////////
UINT GetModKeys(DWORD dwHotKey)
{
UINT result = 0;
WORD wHotKey = HIBYTE(dwHotKey);
if (wHotKey & HOTKEYF_ALT)
result |= MOD_ALT;
if (wHotKey & HOTKEYF_CONTROL)
result |= MOD_CONTROL;
if (wHotKey & HOTKEYF_WIN)
result |= MOD_WIN;
if (wHotKey & HOTKEYF_SHIFT)
result |= MOD_SHIFT;
return result;
}
|