-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDlgSelectMode.cpp
415 lines (325 loc) · 15.3 KB
/
DlgSelectMode.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
// DlgSelectMode.cpp : implementation file
//
#include "StdH.h"
#ifdef _DEBUG
#undef new
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// internal routines for displaying test screen
static void DrawGradient(CDrawPort *pDP, COLOR colStart, COLOR colEnd, PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1)
{
colStart |= CT_OPAQUE;
colEnd |= CT_OPAQUE;
pDP->Fill(pixI0, pixJ0, pixI1 - pixI0, pixJ1 - pixJ0, colStart, colEnd, colStart, colEnd);
}
static void ShowTestModeScreen(CDrawPort *pDP, CViewPort *pVP)
{
// try to lock draw port
#if SE1_VER < SE1_150
if (!pDP->Lock()) {
return;
}
#else
pDP->SetAsCurrent();
#endif
// draw rectangle
PIX dpWidth = pDP->GetWidth();
PIX dpHeight = pDP->GetHeight();
pDP->Fill(C_WHITE | CT_OPAQUE);
pDP->Fill(2, 2, dpWidth - 4, dpHeight - 4, C_BLACK | CT_OPAQUE);
// draw gradients
DrawGradient(pDP, C_WHITE, C_RED, 1.0f / 8 * dpWidth, 1.0f / 16 * dpHeight, 1.0f / 2 * dpWidth, 2.0f / 16 * dpHeight);
DrawGradient(pDP, C_RED, C_BLACK, 1.0f / 2 * dpWidth, 1.0f / 16 * dpHeight, 7.0f / 8 * dpWidth, 2.0f / 16 * dpHeight);
DrawGradient(pDP, C_BLACK, C_GREEN, 1.0f / 8 * dpWidth, 2.0f / 16 * dpHeight, 1.0f / 2 * dpWidth, 3.0f / 16 * dpHeight);
DrawGradient(pDP, C_GREEN, C_WHITE, 1.0f / 2 * dpWidth, 2.0f / 16 * dpHeight, 7.0f / 8 * dpWidth, 3.0f / 16 * dpHeight);
DrawGradient(pDP, C_WHITE, C_BLUE, 1.0f / 8 * dpWidth, 3.0f / 16 * dpHeight, 1.0f / 2 * dpWidth, 4.0f / 16 * dpHeight);
DrawGradient(pDP, C_BLUE, C_BLACK, 1.0f / 2 * dpWidth, 3.0f / 16 * dpHeight, 7.0f / 8 * dpWidth, 4.0f / 16 * dpHeight);
DrawGradient(pDP, C_BLACK, C_CYAN, 1.0f / 8 * dpWidth, 4.5f / 16 * dpHeight, 1.0f / 2 * dpWidth, 5.5f / 16 * dpHeight);
DrawGradient(pDP, C_CYAN, C_WHITE, 1.0f / 2 * dpWidth, 4.5f / 16 * dpHeight, 7.0f / 8 * dpWidth, 5.5f / 16 * dpHeight);
DrawGradient(pDP, C_WHITE, C_MAGENTA, 1.0f / 8 * dpWidth, 5.5f / 16 * dpHeight, 1.0f / 2 * dpWidth, 6.5f / 16 * dpHeight);
DrawGradient(pDP, C_MAGENTA, C_BLACK, 1.0f / 2 * dpWidth, 5.5f / 16 * dpHeight, 7.0f / 8 * dpWidth, 6.5f / 16 * dpHeight);
DrawGradient(pDP, C_BLACK, C_YELLOW, 1.0f / 8 * dpWidth, 6.5f / 16 * dpHeight, 1.0f / 2 * dpWidth, 7.5f / 16 * dpHeight);
DrawGradient(pDP, C_YELLOW, C_WHITE, 1.0f / 2 * dpWidth, 6.5f / 16 * dpHeight, 7.0f / 8 * dpWidth, 7.5f / 16 * dpHeight);
DrawGradient(pDP, C_WHITE, C_BLACK, 1.0f / 8 * dpWidth, 8.0f / 16 * dpHeight, 7.0f / 8 * dpWidth, 10.0f / 16 * dpHeight);
// draw rectangles
pDP->Fill(1.5f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dRED | CT_OPAQUE);
pDP->Fill(1.5f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_RED | CT_OPAQUE);
pDP->Fill(1.5f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lRED | CT_OPAQUE);
pDP->Fill(2.0f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dGREEN | CT_OPAQUE);
pDP->Fill(2.0f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_GREEN | CT_OPAQUE);
pDP->Fill(2.0f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lGREEN | CT_OPAQUE);
pDP->Fill(2.5f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dBLUE | CT_OPAQUE);
pDP->Fill(2.5f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_BLUE | CT_OPAQUE);
pDP->Fill(2.5f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lBLUE | CT_OPAQUE);
pDP->Fill(3.0f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dCYAN | CT_OPAQUE);
pDP->Fill(3.0f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_CYAN | CT_OPAQUE);
pDP->Fill(3.0f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lCYAN | CT_OPAQUE);
pDP->Fill(3.5f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dMAGENTA | CT_OPAQUE);
pDP->Fill(3.5f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_MAGENTA | CT_OPAQUE);
pDP->Fill(3.5f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lMAGENTA | CT_OPAQUE);
pDP->Fill(4.0f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dYELLOW | CT_OPAQUE);
pDP->Fill(4.0f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_YELLOW | CT_OPAQUE);
pDP->Fill(4.0f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lYELLOW | CT_OPAQUE);
pDP->Fill(4.5f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dGRAY | CT_OPAQUE);
pDP->Fill(4.5f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_GRAY | CT_OPAQUE);
pDP->Fill(4.5f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lGRAY | CT_OPAQUE);
pDP->Fill(5.0f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dORANGE | CT_OPAQUE);
pDP->Fill(5.0f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_ORANGE | CT_OPAQUE);
pDP->Fill(5.0f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lORANGE | CT_OPAQUE);
pDP->Fill(5.5f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dBROWN | CT_OPAQUE);
pDP->Fill(5.5f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_BROWN | CT_OPAQUE);
pDP->Fill(5.5f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lBROWN | CT_OPAQUE);
pDP->Fill(6.0f / 8 * dpWidth, 10.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_dPINK | CT_OPAQUE);
pDP->Fill(6.0f / 8 * dpWidth, 11.0f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_PINK | CT_OPAQUE);
pDP->Fill(6.0f / 8 * dpWidth, 11.5f / 16 * dpHeight, 1.0f / 16 * dpWidth, 0.5f / 16 * dpHeight, C_lPINK | CT_OPAQUE);
// set font
pDP->SetFont(_pfdDisplayFont);
// create text to display
CTString strTestMessage = "test screen";
// type messages
pDP->PutTextC(strTestMessage, 1.0f / 4 * dpWidth, 12.5f / 16 * dpHeight, C_dRED | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 2.0f / 4 * dpWidth, 12.5f / 16 * dpHeight, C_RED | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 3.0f / 4 * dpWidth, 12.5f / 16 * dpHeight, C_lRED | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 1.0f / 4 * dpWidth, 13.0f / 16 * dpHeight, C_dGREEN | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 2.0f / 4 * dpWidth, 13.0f / 16 * dpHeight, C_GREEN | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 3.0f / 4 * dpWidth, 13.0f / 16 * dpHeight, C_lGREEN | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 1.0f / 4 * dpWidth, 13.5f / 16 * dpHeight, C_dBLUE | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 2.0f / 4 * dpWidth, 13.5f / 16 * dpHeight, C_BLUE | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 3.0f / 4 * dpWidth, 13.5f / 16 * dpHeight, C_lBLUE | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 1.0f / 4 * dpWidth, 14.0f / 16 * dpHeight, C_dGRAY | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 2.0f / 4 * dpWidth, 14.0f / 16 * dpHeight, C_GRAY | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 3.0f / 4 * dpWidth, 14.0f / 16 * dpHeight, C_lGRAY | CT_OPAQUE);
// type resolution
CDisplayMode dmCurrent;
_pGfx->GetCurrentDisplayMode(dmCurrent);
strTestMessage.PrintF("%d x %d x %s", dpWidth, dpHeight, dmCurrent.DepthString());
pDP->PutTextC(strTestMessage, 1.0f / 2 * dpWidth + 2, 1.0f / 2 * dpHeight + 2, C_dGRAY | CT_OPAQUE);
pDP->PutTextC(strTestMessage, 1.0f / 2 * dpWidth, 1.0f / 2 * dpHeight, C_WHITE | CT_OPAQUE);
#if SE1_VER < SE1_150
// unlock draw port
pDP->Unlock();
#endif
// show screen
pVP->SwapBuffers();
}
// CDlgSelectMode dialog
CDlgSelectMode::CDlgSelectMode(CDisplayMode &dm, enum GfxAPIType &gfxAPI, CWnd *pParent)
: CDialog(CDlgSelectMode::IDD, pParent)
{
// obtain all available modes
m_pdmAvailableModes = _pGfx->EnumDisplayModes(m_ctAvailableDisplayModes);
// remember initial mode reference
m_pdm = &dm;
m_pGfxAPI = &gfxAPI;
//{{AFX_DATA_INIT(CDlgSelectMode)
m_strCurrentMode = _T("");
m_strCurrentDriver = _T("");
m_iColor = -1;
//}}AFX_DATA_INIT
// set current mode and driver strings
CTString str;
str.PrintF("%d x %d x %s", dm.dm_pixSizeI, dm.dm_pixSizeJ, dm.DepthString());
m_strCurrentMode = str;
switch (gfxAPI) {
case GAT_OGL:
m_strCurrentDriver = "OpenGL";
break;
#ifdef SE1_D3D
case GAT_D3D:
m_strCurrentDriver = "Direct3D";
break;
#endif
default:
m_strCurrentDriver = "none";
break;
}
}
CDlgSelectMode::~CDlgSelectMode()
{
}
void CDlgSelectMode::ApplySettings(CDisplayMode *pdm, enum GfxAPIType *m_pGfxAPI)
{
// pass driver type var
*m_pGfxAPI = (GfxAPIType)m_ctrlDriverCombo.GetCurSel();
// determine color mode
DisplayDepth ddDepth;
switch (m_iColor) {
case 0: ddDepth = DD_DEFAULT; break;
case 1: ddDepth = DD_16BIT; break;
case 2: ddDepth = DD_32BIT; break;
default:
ASSERT(FALSE);
ddDepth = DD_DEFAULT;
break;
}
// get resolution
const ULONG ulRes = (ULONG)m_ctrlResCombo.GetItemData(m_ctrlResCombo.GetCurSel());
const PIX pixSizeI = ulRes >> 16;
const PIX pixSizeJ = ulRes & 0xFFFF;
// find potentional corresponding modes
for (INDEX iMode = 0; iMode < m_ctAvailableDisplayModes; iMode++) {
// if found mode that matches in resolution
if (pixSizeI == m_pdmAvailableModes[iMode].dm_pixSizeI && pixSizeJ == m_pdmAvailableModes[iMode].dm_pixSizeJ) {
// get it and set wanted depth
pdm->dm_pixSizeI = pixSizeI;
pdm->dm_pixSizeJ = pixSizeJ;
pdm->dm_ddDepth = ddDepth;
}
}
}
void CDlgSelectMode::DoDataExchange(CDataExchange *pDX)
{
CDialog::DoDataExchange(pDX);
// prepare radio buttons
if (!pDX->m_bSaveAndValidate) {
// set current color radios
switch (m_pdm->dm_ddDepth) {
case DD_DEFAULT: m_iColor = 0; break;
case DD_16BIT: m_iColor = 1; break;
case DD_32BIT: m_iColor = 2; break;
default:
ASSERT(FALSE);
m_iColor = 0;
break;
}
}
//{{AFX_DATA_MAP(CDlgSelectMode)
DDX_Control(pDX, IDC_RESOLUTIONS, m_ctrlResCombo);
DDX_Control(pDX, IDC_API, m_ctrlDriverCombo);
DDX_Text(pDX, IDC_CURRENT_MODE, m_strCurrentMode);
DDX_Text(pDX, IDC_CURRENT_DRIVER, m_strCurrentDriver);
DDX_Radio(pDX, IDC_COLOR_DEFAULT, m_iColor);
//}}AFX_DATA_MAP
// if dialog is recieving data
if (!pDX->m_bSaveAndValidate) {
INDEX i, iSelect = 0;
// clear combo boxes
m_ctrlDriverCombo.ResetContent();
m_ctrlResCombo.ResetContent();
// init driver combo
i = m_ctrlDriverCombo.AddString(_T("OpenGL"));
m_ctrlDriverCombo.SetItemData(i, (INDEX)GAT_OGL);
if (*m_pGfxAPI == GAT_OGL) {
iSelect = i;
}
#ifdef SE1_D3D
i = m_ctrlDriverCombo.AddString(_T("Direct3D"));
m_ctrlDriverCombo.SetItemData(i, (INDEX)GAT_D3D);
if (*m_pGfxAPI == GAT_D3D) {
iSelect = i;
}
#endif
// set old driver to be default
m_ctrlDriverCombo.SetCurSel(iSelect);
// init resolutions combo
iSelect = 0;
for (INDEX iMode = 0; iMode < m_ctAvailableDisplayModes; iMode++) {
// prepare resolution string
CTString strRes;
PIX pixSizeI = m_pdmAvailableModes[iMode].dm_pixSizeI;
PIX pixSizeJ = m_pdmAvailableModes[iMode].dm_pixSizeJ;
strRes.PrintF("%d x %d", pixSizeI, pixSizeJ);
// if not yet added
if (m_ctrlResCombo.FindStringExact(0, CString(strRes)) == CB_ERR) {
// add it to combo box list
i = m_ctrlResCombo.AddString(CString(strRes));
// set item data to match the resolutions (I in upper word, J in lower)
m_ctrlResCombo.SetItemData(i, (pixSizeI << 16) | pixSizeJ);
// if found old full screen mode
if (pixSizeI == m_pdm->dm_pixSizeI && pixSizeJ == m_pdm->dm_pixSizeJ) {
// mark it to be selected by default
iSelect = i;
}
}
}
// set current res combo default mode
m_ctrlResCombo.SetCurSel(iSelect);
}
// if dialog is giving data
if (pDX->m_bSaveAndValidate) {
// apply new display mode settings
ApplySettings(m_pdm, m_pGfxAPI);
}
}
BEGIN_MESSAGE_MAP(CDlgSelectMode, CDialog)
//{{AFX_MSG_MAP(CDlgSelectMode)
ON_BN_CLICKED(ID_TEST_BUTTON, OnTestButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CDlgSelectMode message handlers
void CDlgSelectMode::OnTestButton()
{
CWnd wndTestWindowedMode;
UpdateData(TRUE);
// apply wanted display mode settings
CDisplayMode dm;
enum GfxAPIType gfxAPI;
ApplySettings(&dm, &gfxAPI);
// try to set wanted display mode
PIX pixSizeI = dm.dm_pixSizeI;
PIX pixSizeJ = dm.dm_pixSizeJ;
BOOL bDisplayModeSet = _pGfx->SetDisplayMode(GAT_OGL, 0, pixSizeI, pixSizeJ, dm.dm_ddDepth);
if (!bDisplayModeSet) {
AfxMessageBox(_T("Unable to setup full screen display. Test mode failed."));
return;
}
//--------------------------- Open window for testing windowed display mode
// draw ports and viewports needed for printing message
CDrawPort *pDrawPort;
CViewPort *pViewPort;
// get the windows dimensions for this display
int iScreenX = ::GetSystemMetrics(SM_CXSCREEN); // screen size
int iScreenY = ::GetSystemMetrics(SM_CYSCREEN);
// open window of display mode size
const TCHAR *strWindowClass = AfxRegisterWndClass(CS_OWNDC | CS_NOCLOSE);
wndTestWindowedMode.CreateEx(WS_EX_TOPMOST, strWindowClass, _T("Test mode"),
WS_POPUP | WS_VISIBLE, 0, 0, iScreenX, iScreenY, m_hWnd, 0);
// create window canvas
_pGfx->CreateWindowCanvas(wndTestWindowedMode.m_hWnd, &pViewPort, &pDrawPort);
// if screen or window opening was not successful
if (pViewPort == NULL) {
AfxMessageBox(_T("Unable to setup full screen display. Test mode failed."));
return;
}
// show test mode screen
ShowTestModeScreen(pDrawPort, pViewPort);
// get starting time
CTimerValue tvStart = _pTimer->GetHighPrecisionTimer();
// loop forever
FOREVER {
// get current time
CTimerValue tvCurrent = _pTimer->GetHighPrecisionTimer();
// get time difference in seconds
CTimerValue tvElapsed = tvCurrent - tvStart;
// three seconds passed?
if (tvElapsed.GetSeconds() > 5.0f) {
break;
}
}
// destroy windowed canvas
_pGfx->DestroyWindowCanvas(pViewPort);
pViewPort = NULL;
// destroy window
wndTestWindowedMode.DestroyWindow();
// restore old mode
_pGfx->ResetDisplayMode();
if (AfxMessageBox(_T("Did You see displayed message correctly?"), MB_YESNO) == IDYES) {
GetDlgItem(IDOK)->SetFocus(); // set focus to apply button
} else {
AfxMessageBox(_T("Mode is not valid and it is rejected. Choose another one."));
}
Invalidate(FALSE);
}