-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMyHotkeyCtrl.cpp
62 lines (51 loc) · 1.57 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
// MyHotkeyCtrl.cpp : インプリメンテーション ファイル
//
#include "stdafx.h"
#include "charu3.h"
#include "MyHotkeyCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// 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(!(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;
}
}
}
return CHotKeyCtrl::PreTranslateMessage(pMsg);
}