-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsDialog.cpp
More file actions
207 lines (168 loc) · 4.92 KB
/
SettingsDialog.cpp
File metadata and controls
207 lines (168 loc) · 4.92 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
///////////////////////////////////////
// MyDialog.cpp
#include "stdafx.h"
#include "SettingsDialog.hpp"
#include "resource.h"
/////////////////////////////////////////////
// Definitions for the CButtonDialog class
//
CButtonDialog::CButtonDialog(UINT resID) : CDialog(resID)
{
m_brush.CreateSolidBrush(RGB(255, 255, 255));
}
CButtonDialog::~CButtonDialog()
{
}
INT_PTR CButtonDialog::DialogProc(UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_CTLCOLORDLG: return OnCtlColorDlg(msg, wparam, lparam);
case WM_CTLCOLORSTATIC: return OnCtlColorStatic(msg, wparam, lparam);
}
// Pass unhandled messages on to parent DialogProc
return DialogProcDefault(msg, wparam, lparam);
}
BOOL CButtonDialog::OnCommand(WPARAM wparam, LPARAM lparam)
{
UNREFERENCED_PARAMETER(lparam);
UINT id = LOWORD(wparam);
switch (id)
{
case IDC_BUTTON1: return OnButton();
case IDC_CHECK1: return OnCheck1();
case IDC_CHECK2: return OnCheck2();
case IDC_CHECK3: return OnCheck3();
case IDC_RADIO1:
case IDC_RADIO2: // intentionally blank
case IDC_RADIO3: return OnRangeOfRadioIDs(IDC_RADIO1, IDC_RADIO3, id);
}
return FALSE;
}
BOOL CButtonDialog::OnButton()
{
TRACE("Push Button Pressed\n");
return TRUE;
}
BOOL CButtonDialog::OnCheck1()
{
TRACE("Check Box 1\n");
return TRUE;
}
BOOL CButtonDialog::OnCheck2()
{
TRACE("Check Box 2\n");
return TRUE;
}
BOOL CButtonDialog::OnCheck3()
{
TRACE("Check Box 3\n");
return TRUE;
}
INT_PTR CButtonDialog::OnCtlColorDlg(UINT msg, WPARAM wparam, LPARAM lparam)
{
// Set the background color of the dialog
if (IsXPThemed())
return reinterpret_cast<INT_PTR>(m_brush.GetHandle());
else
return FinalWindowProc(msg, wparam, lparam);
}
INT_PTR CButtonDialog::OnCtlColorStatic(UINT msg, WPARAM wparam, LPARAM lparam)
{
// Set the background color of static controls
if (IsXPThemed())
return reinterpret_cast<INT_PTR>(m_brush.GetHandle());
else
return FinalWindowProc(msg, wparam, lparam);
}
BOOL CButtonDialog::OnRangeOfRadioIDs(UINT firstID, UINT lastID, UINT clickedID)
{
CheckRadioButton(firstID, lastID, clickedID);
CString str;
int button = clickedID - firstID + 1;
str.Format(_T("Radio%d"), button);
TRACE(str); TRACE("\n");
return TRUE;
}
/////////////////////////////////////////////
// Definitions for the CComboBoxDialog class
//
CComboBoxDialog::CComboBoxDialog(UINT resID) : CDialog(resID)
{
m_brush.CreateSolidBrush(RGB(255, 255, 255));
}
CComboBoxDialog::~CComboBoxDialog()
{
}
INT_PTR CComboBoxDialog::DialogProc(UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
// Set the background color of the dialog
case WM_CTLCOLORDLG:
if (IsXPThemed()) return reinterpret_cast<INT_PTR>(m_brush.GetHandle());
break;
// Set the background color of static controls
case WM_CTLCOLORSTATIC:
if (IsXPThemed()) return reinterpret_cast<INT_PTR>(m_brush.GetHandle());
break;
}
// Pass unhandled messages on to parent DialogProc
return DialogProcDefault(msg, wparam, lparam);
}
BOOL CComboBoxDialog::OnInitDialog()
{
// Put some text in the Combo Boxes
for (int i = 0 ; i < 6 ; i++)
{
SendDlgItemMessage(IDC_COMBO1, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_T("C Box 1")));
SendDlgItemMessage(IDC_COMBO2, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_T("C Box 2")));
SendDlgItemMessage(IDC_COMBO3, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_T("C Box 3")));
}
return TRUE;
}
/////////////////////////////////////////
// Definitions for the CSettingsDialog class
//
CSettingsDialog::CSettingsDialog(UINT resID) : CDialog(resID)
{
m_pButtonDlg = NULL;
m_pComboDlg = NULL;
}
CSettingsDialog::~CSettingsDialog()
{
}
INT_PTR CSettingsDialog::DialogProc(UINT msg, WPARAM wparam, LPARAM lparam)
{
// switch (msg)
// {
//
// }
// Pass unhandled messages on to parent DialogProc
return DialogProcDefault(msg, wparam, lparam);
}
void CSettingsDialog::OnDestroy()
{
// End the application
//::PostQuitMessage(0);
}
BOOL CSettingsDialog::OnInitDialog()
{
// Set the Icon
SetIconLarge(IDI_SETTINGS);
SetIconSmall(IDI_SETTINGS);
AttachItem(IDC_TAB1, m_tab);
m_pButtonDlg = static_cast<CButtonDialog*>(m_tab.AddTabPage(new CButtonDialog(IDD_BUTTONS), _T("Button Dialog")));
m_pComboDlg = static_cast<CComboBoxDialog*>(m_tab.AddTabPage(new CComboBoxDialog(IDD_COMBOBOXES), _T("ComboBox Dialog")));
m_tab.SelectPage(0);
// Add some checkmarks to buttons to the button dialog
m_pButtonDlg->CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO2);
m_pButtonDlg->CheckDlgButton(IDC_CHECK1, BST_CHECKED);
return TRUE;
}
void CSettingsDialog::OnOK()
{
// This is called when the Enter key is pressed
// Do default action (i.e. close the dialog)
CDialog::OnOK();
}