forked from keizi666/charu3
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
OptKeySetEditDlg.cpp
148 lines (129 loc) · 4.72 KB
/
OptKeySetEditDlg.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// OptKeySetEditDlg.cpp : インプリメンテーション ファイル
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "OptKeySetEditDlg.h"
#include "key.h"
#include "resource.h"
namespace {
//---------------------------------------------------
//関数名 EnumWindowTitle
//機能 ウィンドウの名前を列挙
//---------------------------------------------------
BOOL CALLBACK EnumWindowTitle(HWND hwnd, LPARAM lParam)
{
CComboBox* combo = (CComboBox*)lParam;
if (combo) {
TCHAR WindowName[1024] = {};
*WindowName = (char)NULL;
if (IsWindowVisible(hwnd)) {
int resalt = GetWindowText(hwnd, WindowName, _countof(WindowName));
if (resalt && _tcsclen(WindowName) > 0) {
combo->AddString(WindowName);
}
}
return TRUE;
}
else {
return FALSE;
}
}
} // anonymous namespace
/////////////////////////////////////////////////////////////////////////////
// COptKeySetEditDlg ダイアログ
COptKeySetEditDlg::COptKeySetEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(COptKeySetEditDlg::IDD, pParent)
, m_pasteMessage(_T(""))
, m_copyMessage(_T(""))
, m_keyAction(-1)
, m_matchCombo(-1)
, m_caption(_T(""))
, m_copyWait(0)
, m_pasteWait(0)
, m_nHistoryLimit(-1)
{
}
void COptKeySetEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptKeySetEditDlg)
//}}AFX_DATA_MAP
if (GetDlgItem(IDC_OPT_WINCAP_COMBO)) {
DDX_CBString(pDX, IDC_OPT_WINCAP_COMBO, m_caption);
}
if (GetDlgItem(IDC_OPT_MATCH_COMBO)) {
DDX_CBIndex(pDX, IDC_OPT_MATCH_COMBO, m_matchCombo);
}
if (GetDlgItem(IDC_OPT_COPYKEY2)) {
DDX_Control(pDX, IDC_OPT_COPYKEY2, m_copyKey);
}
if (GetDlgItem(IDC_OPT_PASTKEY2)) {
DDX_Control(pDX, IDC_OPT_PASTKEY2, m_pasteKey);
}
if (GetDlgItem(IDC_OPT_COPY_WAIT2)) {
DDX_Text(pDX, IDC_OPT_COPY_WAIT2, m_copyWait);
// Not worked correctly
//DDV_MinMaxInt(pDX, m_copyWait, 0, 1000);
}
if (GetDlgItem(IDC_OPT_PASTE_WAIT2)) {
DDX_Text(pDX, IDC_OPT_PASTE_WAIT2, m_pasteWait);
// Not worked correctly
//DDV_MinMaxInt(pDX, m_pasteWait, 0, 1000);
}
if (GetDlgItem(IDC_OPT_HISTORY_SIZE_LIMIT)) {
DDX_Text(pDX, IDC_OPT_HISTORY_SIZE_LIMIT, m_nHistoryLimit);
}
if (!pDX->m_bSaveAndValidate) {
UINT uMod = m_key.m_sCopyPasteKey.m_uMod_Paste;
if (m_key.m_sCopyPasteKey.m_uVK_Paste >= 0x60)
m_pasteKey.SetHotKey(m_key.m_sCopyPasteKey.m_uVK_Paste, KeyHelper::ModToHotkey(uMod));
else
m_pasteKey.SetHotKey(m_key.m_sCopyPasteKey.m_uVK_Paste, KeyHelper::ModToHotkey(uMod) | HOTKEYF_EXT);
uMod = m_key.m_sCopyPasteKey.m_uMod_Copy;
if (m_key.m_sCopyPasteKey.m_uVK_Copy >= 0x60)
m_copyKey.SetHotKey(m_key.m_sCopyPasteKey.m_uVK_Copy, KeyHelper::ModToHotkey(uMod));
else
m_copyKey.SetHotKey(m_key.m_sCopyPasteKey.m_uVK_Copy, KeyHelper::ModToHotkey(uMod) | HOTKEYF_EXT);
}
else {
CHANGE_KEY key;
WORD wMod, wVkCode;
key.m_nHistoryLimit = m_nHistoryLimit;
//ペーストキー変換
m_pasteKey.GetHotKey(wVkCode, wMod);
key.m_sCopyPasteKey.m_uMod_Paste = KeyHelper::HotkeyToMod(wMod);
key.m_sCopyPasteKey.m_uVK_Paste = wVkCode;
//コピーキー変換
m_copyKey.GetHotKey(wVkCode, wMod);
key.m_sCopyPasteKey.m_uMod_Copy = KeyHelper::HotkeyToMod(wMod);
key.m_sCopyPasteKey.m_uVK_Copy = wVkCode;
_stscanf_s(m_pasteMessage, _T("%x,%x,%x"), &key.m_sCopyPasteKey.m_pasteMessage.Msg,
&key.m_sCopyPasteKey.m_pasteMessage.wParam,
&key.m_sCopyPasteKey.m_pasteMessage.lParam);
_stscanf_s(m_copyMessage, _T("%x,%x,%x"), &key.m_sCopyPasteKey.m_copyMessage.Msg,
&key.m_sCopyPasteKey.m_copyMessage.wParam,
&key.m_sCopyPasteKey.m_copyMessage.lParam);
key.m_sCopyPasteKey.m_nMessage = m_keyAction;
key.m_nMatch = m_matchCombo;
key.m_strTitle = m_caption;
key.m_sCopyPasteKey.m_nCopyWait = m_copyWait;
key.m_sCopyPasteKey.m_nPasteWait = m_pasteWait;
m_key = key;
}
}
BEGIN_MESSAGE_MAP(COptKeySetEditDlg, CDialog)
//{{AFX_MSG_MAP(COptKeySetEditDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COptKeySetEditDlg メッセージ ハンドラ
BOOL COptKeySetEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
::EnumWindows(&EnumWindowTitle, (LPARAM)GetDlgItem(IDC_OPT_WINCAP_COMBO));
return TRUE;
}