forked from keizi666/charu3
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMyHotkeyCtrl.cpp
72 lines (63 loc) · 2.04 KB
/
MyHotkeyCtrl.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// MyHotkeyCtrl.cpp : インプリメンテーション ファイル
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "MyHotkeyCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CMyHotkeyCtrl
CMyHotkeyCtrl::CMyHotkeyCtrl()
{
m_lastKey = NULL;
m_mod = NULL;
}
CMyHotkeyCtrl::~CMyHotkeyCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyHotkeyCtrl, CHotKeyCtrl)
//{{AFX_MSG_MAP(CMyHotkeyCtrl)
// メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します。
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyHotkeyCtrl メッセージ ハンドラ
BOOL CMyHotkeyCtrl::PreTranslateMessage(MSG* pMsg)
{
if (this->GetFocus() == this) {
#if false
/*
* I don't understand the purpose of this code.
*/
if (!(pMsg->lParam & 0x40000000) && (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)) {
m_mod = 0;
if (::GetAsyncKeyState(VK_MENU) < 0) m_mod = m_mod | HOTKEYF_ALT;
if (::GetAsyncKeyState(VK_CONTROL) < 0) m_mod = m_mod | HOTKEYF_CONTROL;
if (::GetAsyncKeyState(VK_SHIFT) < 0) m_mod = m_mod | HOTKEYF_SHIFT;
if (pMsg->wParam != 0x11 && pMsg->wParam != 0x12)// m_lastKey = NULL;
m_lastKey = pMsg->wParam;
}
else if (pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP) {
SetHotKey(m_lastKey, m_mod);
return 0;
}
if (pMsg->message == WM_SYSKEYDOWN) {
if (pMsg->wParam == 'C') {
this->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
pMsg->message = NULL;
}
}
#else
/*
* This is enough, I think.
*/
if (pMsg->message == WM_SYSKEYDOWN) {
this->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
#endif
return CHotKeyCtrl::PreTranslateMessage(pMsg);
}