forked from keizi666/charu3
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOptMainDialog.cpp
170 lines (150 loc) · 5.11 KB
/
OptMainDialog.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*----------------------------------------------------------
設定メインクラス
2002/11/16 (c)Keizi
----------------------------------------------------------*/
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "OptMainDialog.h"
#include "Charu3.h"
#include "hotkey.h"
#include "resource.h"
#include "log.h"
//---------------------------------------------------
//関数名 COptMainDialog
//機能 コンストラクタ
//---------------------------------------------------
COptMainDialog::COptMainDialog(CWnd* pParent /*=NULL*/, int nPage)
: CDialog(COptMainDialog::IDD, pParent)
, m_pages{ &m_general, &m_style, &m_popup, &m_fifo, &m_key, &m_advanced }
, m_nPageNo(nPage)
{
}
//---------------------------------------------------
//関数名 DoDataExchange(CDataExchange* pDX)
//機能 データエクスチェンジ
//---------------------------------------------------
void COptMainDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptMainDialog)
if (GetDlgItem(IDC_OPT_TAB))
DDX_Control(pDX, IDC_OPT_TAB, m_ctrlTab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptMainDialog, CDialog)
//{{AFX_MSG_MAP(COptMainDialog)
ON_NOTIFY(TCN_SELCHANGE, IDC_OPT_TAB, OnSelchangeOptTab)
ON_WM_SHOWWINDOW()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//---------------------------------------------------
// COptMainDialog メッセージ ハンドラ
//---------------------------------------------------
//---------------------------------------------------
//関数名 OnInitDialog()
//機能 初期化
//---------------------------------------------------
BOOL COptMainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
for (int i = 0; i < NUM_PAGES; i++) {
CString strTabText;
(void)strTabText.LoadString(APP_INF_TABNAME_01 + i);
TC_ITEM item = {};
item.mask = TCIF_TEXT;
item.pszText = (TCHAR*)LPCTSTR(strTabText);
m_ctrlTab.InsertItem(i, &item);
}
CRect rect;
m_ctrlTab.GetWindowRect(&rect);
m_ctrlTab.AdjustRect(FALSE, &rect);
ScreenToClient(&rect);
m_nPageNo = theApp.m_ini.m_nOptionPage;
const int nDialogID[] = { IDD_SETTINGS_01_GENERAL, IDD_SETTINGS_02_STYLE, IDD_SETTINGS_03_DATATREE, IDD_SETTINGS_04_STOCKMODE, IDD_SETTINGS_05_KEYS, IDD_SETTINGS_06_ADVANCED };
for (int i = 0; i < NUM_PAGES; i++) {
m_pages[i]->Create(nDialogID[i], this);
m_pages[i]->MoveWindow(&rect);
m_pages[i]->ShowWindow(i == m_nPageNo ? SW_SHOW : SW_HIDE);
m_ctrlTab.HighlightItem(i, i == m_nPageNo);
}
m_ctrlTab.SetCurFocus(m_nPageNo);
return FALSE; // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
// 例外: OCX プロパティ ページの戻り値は FALSE となります
}
//---------------------------------------------------
//関数名 OnSelchangeOptTab(NMHDR* pNMHDR, LRESULT* pResult)
//機能 タブ切り替え処理
//---------------------------------------------------
void COptMainDialog::OnSelchangeOptTab(NMHDR* pNMHDR, LRESULT* pResult)
{
m_nPageNo = m_ctrlTab.GetCurSel();
for (int i = 0; i < NUM_PAGES; i++) {
m_pages[i]->ShowWindow(i == m_nPageNo ? SW_SHOW : SW_HIDE);
m_ctrlTab.HighlightItem(i, i == m_nPageNo);
}
*pResult = 0;
}
//---------------------------------------------------
//関数名 DestroyWindow()
//機能 ウィンドウ破棄処理
//---------------------------------------------------
BOOL COptMainDialog::DestroyWindow()
{
theApp.RedrawDataTreeView();
for (int i = 0; i < NUM_PAGES; i++) {
m_pages[i]->UpdateData();
m_pages[i]->DestroyWindow();
}
theApp.m_ini.m_nOptionPage = m_nPageNo;
return CDialog::DestroyWindow();
}
void COptMainDialog::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
void COptMainDialog::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
if (WA_INACTIVE == nState) {
UnregisterHotKey(this->m_hWnd, HOTKEY_TAB_NEXT);
UnregisterHotKey(this->m_hWnd, HOTKEY_TAB_PREV);
}
else {
RegisterHotKey(this->m_hWnd, HOTKEY_TAB_NEXT, MOD_CONTROL, VK_TAB);
RegisterHotKey(this->m_hWnd, HOTKEY_TAB_PREV, MOD_CONTROL | MOD_SHIFT, VK_TAB);
}
}
//---------------------------------------------------
// メッセージ前処理
//---------------------------------------------------
BOOL COptMainDialog::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_HOTKEY) {
switch (pMsg->wParam) {
case HOTKEY_TAB_NEXT:
if (m_nPageNo < NUM_PAGES - 1) {
++m_nPageNo;
}
else {
m_nPageNo = 0;
}
m_ctrlTab.SetCurFocus(m_nPageNo);
break;
case HOTKEY_TAB_PREV:
if (m_nPageNo > 0) {
--m_nPageNo;
}
else {
m_nPageNo = NUM_PAGES - 1;
}
m_ctrlTab.SetCurFocus(m_nPageNo);
break;
}
}
return CDialog::PreTranslateMessage(pMsg);
}