-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButtonTabCtrl.cpp
More file actions
695 lines (631 loc) · 15.2 KB
/
ButtonTabCtrl.cpp
File metadata and controls
695 lines (631 loc) · 15.2 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
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
// ButtonTabCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "CoolTabCtrl.h"
#include "ButtonTabCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ITEMBUTTON_HEIGHT 17
/////////////////////////////////////////////////////////////////////////////
// CBottonTabCtrl
/////////////////////////////////////////////////////////////////////////////
// CBottonTabCtrl message handlers
IMPLEMENT_DYNCREATE(CBottonTabCtrl, CWnd)
static CPen _penW(PS_SOLID,1 ,RGB(255,255,255));
static CPen _penB(PS_SOLID,1 ,RGB(0,0,0));
static CPen _penGray(PS_SOLID,1,GetSysColor(COLOR_GRAYTEXT));
static CPen _pen3DFace(PS_SOLID,1,GetSysColor(COLOR_3DFACE));
static CPen _pen3DLight(PS_SOLID,1,GetSysColor(COLOR_3DLIGHT));
static CPen _pen3DShadow(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW));
static CPen _pen3DDKShadow(PS_SOLID,1,GetSysColor(COLOR_3DDKSHADOW));
int DoubleRound(double d)
{
int re=(int)d;
double temp=d-re;
if(temp>0.5)
{
return (re+1);
}
else
{
return re;
}
}
CBottonTabCtrl::CBottonTabCtrl()
{
m_nStyle = TCS_DOWN;
m_nActivePage = -1;
m_nBorder = 2;
m_bEraseBkgnd = TRUE;
}
CBottonTabCtrl::~CBottonTabCtrl()
{
POSITION pos;
CPageItem* pItem;
for(pos=m_PageList.GetHeadPosition();pos!=NULL;)
{
pItem=(CPageItem*)m_PageList.GetNext(pos);
if(pItem)
{
if(pItem->m_nStyle == 1 && pItem->m_pWnd) // 动态创建
{
pItem->m_pWnd->DestroyWindow();
delete pItem->m_pWnd;
}
delete pItem;
pItem=NULL;
}
}
m_PageList.RemoveAll();
}
BEGIN_MESSAGE_MAP(CBottonTabCtrl, CWnd)
//{{AFX_MSG_MAP(CBottonTabCtrl)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_SIZING()
ON_WM_SIZE()
ON_WM_TIMER()
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBottonTabCtrl message handlers
BOOL CBottonTabCtrl::Create(UINT wStyle, const CRect &rect, CWnd *pParentWnd, UINT nID)
{
m_nStyle = wStyle & TCS_MASK;
if(m_nStyle == 0)
m_nStyle = TCS_UP;
if (CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW), (HBRUSH)GetStockObject(LTGRAY_BRUSH), NULL),
NULL,
wStyle&~TCS_MASK | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
rect,
pParentWnd,
nID))
{
return TRUE;
}
return FALSE;
}
BOOL CBottonTabCtrl::OnEraseBkgnd(CDC* pDC)
{
if(m_bEraseBkgnd)
{
CRect rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
CBrush brush(GetSysColor(COLOR_3DFACE));
pDC->FillRect(rect,&brush);
}
return TRUE;
}
void CBottonTabCtrl::OnPaint()
{
CPaintDC dc(this);
CPen *pOldPen = dc.GetCurrentPen();
CFont *pOldFont = dc.SelectObject(&m_font);
int nOldBkMode = dc.SetBkMode(TRANSPARENT);
CPageItem *pItem;
POSITION pos,tempPos;
int nItemIndex = 0;
DrawFrame(&dc);
BOOL bIsFirstPage=TRUE;
for(pos=m_PageList.GetHeadPosition();pos!=NULL;nItemIndex++)
{
UINT state=ITEM_STATE_NOMAL;
pItem=(CPageItem*)m_PageList.GetNext(pos);
tempPos=pos;
if(pItem)
{
if(m_nActivePage==nItemIndex)
{
state=ITEM_STATE_ACTIVE;
}
else if(pos==NULL) //表明是最后一项
{
state=ITEM_STATE_LAST_ITEM;
}
else
{
state=ITEM_STATE_NOMAL;
}
pItem->Draw(&dc,m_nStyle,state,bIsFirstPage);
bIsFirstPage=FALSE;
}
}
dc.SetBkMode(nOldBkMode);
dc.SelectObject(pOldFont);
dc.SelectObject(pOldPen);
}
CBottonTabCtrl::CPageItem* CBottonTabCtrl::AddPage(CWnd *pWnd, LPCWSTR sText, UINT IconID)
{
ASSERT(pWnd);
ASSERT(IsWindow(pWnd->m_hWnd));
CPageItem *pItem = NULL;
pItem = new CPageItem();
pItem->m_pWnd = pWnd;
pItem->m_nStyle = 0; //Window
pItem->m_sText = sText;
if(IconID)
pItem->m_hIcon = AfxGetApp()->LoadIcon(IconID);
else
pItem->m_hIcon = NULL;
CRect rect;
GetClientRect(rect);
pWnd->MoveWindow(rect);
m_PageList.AddTail(pItem);
// 如果添加的Page index不等于m_nActivePage, 则隐藏
if(m_nActivePage != m_PageList.GetCount())
{
pWnd->ShowWindow(SW_HIDE);
}
return pItem;
}
void CBottonTabCtrl::GetClientRect(LPRECT lpRect)
{
CWnd::GetClientRect(lpRect);
if(m_nStyle&TCS_DOWN)
{
lpRect->left += 2;
lpRect->right -= 2;
lpRect->top += 2;
lpRect->bottom -= ITEMBUTTON_HEIGHT;
}
else if(m_nStyle&TCS_UP)
{
lpRect->left += 2;
lpRect->right -= 2;
lpRect->top += ITEMBUTTON_HEIGHT;
lpRect->bottom -= 2;
}
}
///////取得需要占用的宽度/////
CPoint CBottonTabCtrl::CPageItem::m_arrPoint[6];
UINT CBottonTabCtrl::CPageItem::GetAreaWidth(CDC *pDC)
{
UINT width = pDC->GetTextExtent(m_sText).cx+35;
if(m_hIcon)
width += 18;
return (UINT)(width + (double)ITEMBUTTON_HEIGHT*2/1.732);
}
void CBottonTabCtrl::CPageItem::Draw(CDC *pDC, UINT nStyle, UINT state,BOOL bIsFirstLabel)
{
CRect rect = m_rect;
CPen * pOldPen;
CBrush * pOldBrush;
double dTemp=(double)m_rect.Height()/1.732;
if(nStyle&TCS_DOWN)
{
// if(bActive)
// {
// rect.top -= 2;
// CBrush brush(GetSysColor(COLOR_3DFACE));
// pDC->FillRect(rect,&brush);
// rect.top += 1;
// }
// else
// rect.bottom -= 1;
pOldPen=pDC->SelectObject(&_penB);
if(bIsFirstLabel)
{
m_arrPoint[4].x=rect.left;
m_arrPoint[4].y=rect.top;
m_arrPoint[3].x=DoubleRound((double)m_arrPoint[4].x+dTemp*2/3);
m_arrPoint[3].y=DoubleRound((double)m_arrPoint[4].y+(double)rect.Height()*2/3);
rect.left+=DoubleRound(dTemp/3);
}
m_arrPoint[0]=m_arrPoint[3];
m_arrPoint[5]=m_arrPoint[4];
m_arrPoint[1].x=DoubleRound((double)rect.left+dTemp*2/3);
m_arrPoint[1].y=rect.bottom;
m_arrPoint[2].x = (long)(rect.right-dTemp);
m_arrPoint[2].y=rect.bottom;
m_arrPoint[3].x=DoubleRound(m_arrPoint[2].x+dTemp/3);
m_arrPoint[3].y=DoubleRound(m_arrPoint[2].y-dTemp/3);
switch(state)
{
case ITEM_STATE_ACTIVE:
{
//此页最激活时
m_arrPoint[4].x=rect.right;
m_arrPoint[4].y=rect.top;
CBrush tempBrush(RGB(255,255,255));
pOldBrush=pDC->SelectObject(&tempBrush);
pDC->Polygon(m_arrPoint,6);
pOldPen=pDC->SelectObject(&_penW);
pDC->MoveTo(m_arrPoint[4]);
pDC->LineTo(m_arrPoint[5]);
pDC->SelectObject(pOldPen);
break;
}
case ITEM_STATE_NOMAL:
{
//triangle指两个页标签所夹的三角形
m_arrPoint[4].x=DoubleRound((double)m_arrPoint[2].x-dTemp/3);
m_arrPoint[4].y=rect.top;
CBrush tempBrush(GetSysColor(COLOR_3DFACE));
pOldBrush=pDC->SelectObject(&tempBrush);
pDC->Polygon(m_arrPoint,6);
break;
}
case ITEM_STATE_LAST_ITEM:
{
//最后一页
m_arrPoint[4].x=rect.right;
m_arrPoint[4].y=rect.top;
CBrush tempBrush(GetSysColor(COLOR_3DFACE));
pOldBrush=pDC->SelectObject(&tempBrush);
pDC->Polygon(m_arrPoint,6);
break;
}
}
pDC->SelectObject(&_penGray);
pDC->MoveTo(m_arrPoint[1]);
pDC->LineTo(m_arrPoint[2]);
}//end of TCS_DOWN
// else if(nStyle&TCS_UP)
// {
// CBrush brush(GetSysColor(COLOR_3DFACE));
// if(bActive)
// {
// rect.bottom += 1;
// pDC->FillRect(rect,&brush);
// rect.bottom -= 1;
// }
// else
// {
// rect.top += 2;
// pDC->FillRect(rect,&brush);
// }
// pDC->SelectObject(&_penW);
// pDC->MoveTo(rect.left,rect.bottom);
// pDC->LineTo(rect.left,rect.top + 2);
// pDC->LineTo(rect.left + 2,rect.top);
// pDC->LineTo(rect.right,rect.top);
//
// pDC->SelectObject(&_pen3DShadow);
// pDC->MoveTo(rect.right - 1,rect.top);
// pDC->LineTo(rect.right - 1,rect.bottom);
//
// pDC->SelectObject(&_penB);
// pDC->MoveTo(rect.right,rect.top + 1);
// pDC->LineTo(rect.right,rect.bottom);
// }
///////////调整位置//////////
rect.left += (long)(dTemp+5);
rect.right -= (long)(dTemp+5);
///////////显示图标//////////
// if(rect.Width() > 16 && m_hIcon != NULL)
// {
// ::DrawIconEx(pDC->m_hDC,rect.left,rect.top + 3,m_hIcon,16,16,0,NULL,DI_NORMAL);
// rect.left += 18;
// }
if (!m_sText.IsEmpty())
{
///////////显示文字//////////
rect.top += 5;
CString sText = m_sText;
int l = sText.GetLength();
int i;
for(i=0;i<10 && pDC->GetTextExtent(sText).cx > rect.Width();i++,l-=2)
sText = sText.Left(l-2);
if(i > 0)
{
sText = sText.Left(l-2);
sText += _T("...");
}
CFont *pOldFont,tempFont;
LOGFONT longFont;
pOldFont=pDC->GetCurrentFont();
pOldFont->GetLogFont(&longFont);
longFont.lfWeight|=FW_BOLD;
tempFont.CreateFontIndirect(&longFont);
if(state==ITEM_STATE_ACTIVE)
{
pDC->SelectObject(&tempFont);
pDC->DrawText(sText, &rect, DT_LEFT /*| DT_VCENTER */| DT_SINGLELINE);
pDC->SelectObject(pOldFont);
}
else
{
pDC->DrawText(sText, &rect, DT_LEFT /*| DT_VCENTER */| DT_SINGLELINE);
}
}
}
////调整尺寸////
void CBottonTabCtrl::AutoSize()
{
UINT PageCount = m_PageList.GetCount();
if(PageCount < 1) return;
CPageItem *pItem;
POSITION pos;
CRect rect,ClientRect,ItemRect;
GetClientRect(ClientRect);
ClientRect.DeflateRect(m_nBorder+1,m_nBorder+1);
GetWindowRect(rect);
ScreenToClient(rect);
CDC* pDC = GetDC();
CFont *pOldFont = pDC->SelectObject(&m_font);
if(m_nStyle&TCS_DOWN)
{
rect.left += 1;
rect.right -= 6;
rect.bottom -= 1;
rect.top = rect.bottom - ITEMBUTTON_HEIGHT + 1;
}
// else if(m_nStyle&TCS_UP)
// {
// rect.left += 2;
// rect.right -= 6;
// rect.bottom = rect.top + ITEMBUTTON_HEIGHT;
// }
m_rectLabel=rect;
ClientRect.bottom=m_rectLabel.top;
ItemRect = rect;
int AreaWidth = 0,ItemMaxWidth,ItemIndex=0;
ItemMaxWidth = rect.Width()/m_PageList.GetCount();
////////设置按钮初始宽度,并得到按钮所需占用的总宽度///////
for(pos=m_PageList.GetHeadPosition();pos!=NULL;ItemIndex++)
{
pItem=(CPageItem*)m_PageList.GetNext(pos);
if(pItem)
{
ItemMaxWidth=pItem->GetAreaWidth(pDC);
AreaWidth += ItemMaxWidth;
ItemRect.right = ItemRect.left+ItemMaxWidth;
pItem->m_rect = ItemRect;
ItemRect.left = DoubleRound((double)ItemRect.right-ITEMBUTTON_HEIGHT/1.732);
if(pItem->m_pWnd)
pItem->m_pWnd->MoveWindow(ClientRect);
}
}
////////当需要的空间大于实际空间时进行调整////
// if(AreaWidth > rect.Width() && !bMonoSpace)
// {
// ItemRect = rect;
// int AreaWidth,MaxWidth = rect.Width()/PageCount;
// for(pos=m_PageList.GetHeadPosition();pos!=NULL;)
// {
// pItem=(CPageItem*)m_PageList.GetNext(pos);
// if(pItem)
// {
// AreaWidth = pItem->GetAreaWidth(pDC);
// ItemMaxWidth = (ItemMaxWidth < AreaWidth)?MaxWidth:AreaWidth;
// ItemRect.right = ItemRect.left+ItemMaxWidth;
// pItem->m_rect = ItemRect;
// ItemRect.left = ItemRect.right + 1;
// }
// }
// }
pDC->SelectObject(pOldFont);
ReleaseDC(pDC);
}
void CBottonTabCtrl::SetActivePage(int nIndex)
{
if(nIndex == m_nActivePage)
return;
CPageItem *pOldItem,*pItem;
if(m_nActivePage >= 0)
{
pOldItem = (CPageItem*)GetPageItem(m_nActivePage);
if(pOldItem)
{
pOldItem->m_pWnd->ShowWindow(SW_HIDE);
}
}
pItem = (CPageItem*)GetPageItem(nIndex);
if(!pItem) return;
m_nActivePage = nIndex;
if(m_nStyle&TCS_ANIMATE)
SetTimer(100,15,NULL);///为了在95或NT4下也有动画效果,没有使用AnimateWindow函数
else
pItem->m_pWnd->ShowWindow(SW_SHOW);
}
void* CBottonTabCtrl::GetPageItem(UINT nIndex)
{
CPageItem *pItem = NULL;
POSITION pos = m_PageList.FindIndex(nIndex);
if(pos)
pItem = (CPageItem*)m_PageList.GetAt(pos);
return pItem;
}
void CBottonTabCtrl::UpdateWindow()
{
AutoSize();
if(m_nActivePage < 0)
SetActivePage(0);
else
SetActivePage(m_nActivePage);
Invalidate();
}
void CBottonTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT nItemIndex=0;
POSITION pos;
CPageItem *pItem;
for(pos=m_PageList.GetHeadPosition();pos!=NULL;nItemIndex++)
{
pItem=(CPageItem*)m_PageList.GetNext(pos);
if(pItem)
{
if(pItem->m_rect.PtInRect(point))
{
SetActivePage(nItemIndex);
Invalidate();
break;
}
}
}
CWnd::OnLButtonDown(nFlags, point);
}
void CBottonTabCtrl::OnSizing(UINT fwSide, LPRECT pRect)
{
CWnd::OnSizing(fwSide, pRect);
m_bEraseBkgnd = FALSE;
AutoSize();
}
void CBottonTabCtrl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
m_bEraseBkgnd = TRUE;
AutoSize();
Invalidate();
}
void CBottonTabCtrl::DrawFrame(CDC *pDC)
{
CRect rect;
GetWindowRect(rect);
ScreenToClient(rect);
switch(m_nBorder)
{
case 1:
pDC->Draw3dRect(rect,RGB(0,0,0),RGB(0xff,0xff,0xff));
break;
case 2:
pDC->Draw3dRect(rect, GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_3DSHADOW));
rect.DeflateRect(2, 2);
pDC->Draw3dRect(rect,RGB(0,0,0),RGB(0xff,0xff,0xff));
break;
default:break;
}
CBrush brush(GetSysColor(COLOR_3DFACE));
pDC->FillRect(m_rectLabel,&brush);
}
void CBottonTabCtrl::SetStyle(UINT style)
{
m_nStyle = style;
}
UINT CBottonTabCtrl::GetStyle()
{
return m_nStyle;
}
void CBottonTabCtrl::OnTimer(UINT nIDEvent)
{
static step,times = 10;
UINT width;
CRect rect;
GetClientRect(&rect);
rect.DeflateRect(m_nBorder+1,m_nBorder+1);
POSITION pos = m_PageList.FindIndex(m_nActivePage);
if(pos)
{
CPageItem *pItem = (CPageItem*)m_PageList.GetAt(pos);
if(pItem)
{
width = rect.Width();
if(times == 10)
{
rect.right = 10;
rect.left = rect.right - width + 1;
step = width/times;
times--;
m_bEraseBkgnd = FALSE;
pItem->m_pWnd->ShowWindow(SW_SHOW);
}
else
{
if(times <= 0)
{
times = 10;
KillTimer(nIDEvent);
m_bEraseBkgnd = TRUE;
}
else
{
rect.right = width - times*step;
rect.left = rect.right - width + 1;
times--;
}
}
pItem->m_pWnd->MoveWindow(rect);
}
}
}
void CBottonTabCtrl::SetStyleAnimate(BOOL bEnable)
{
UINT style = GetStyle();
if(bEnable)
style |= TCS_ANIMATE;
else
style &= ~TCS_ANIMATE;
SetStyle(style);
}
void CBottonTabCtrl::SetStyleDirection(int Direction)
{
UINT style = GetStyle();
switch(Direction)
{
case TCS_DOWN:
style &= ~TCS_UP;
style |= TCS_DOWN;
break;
case TCS_UP:
default:
style &= ~TCS_DOWN;
style |= TCS_UP;
break;
}
SetStyle(style);
UpdateWindow();
}
void CBottonTabCtrl::SetStyleMonoSpace(BOOL bEnable)
{
UINT style = GetStyle();
// if(bEnable)
// style |= TCS_MONOSPACE;
// else
// style &= ~TCS_MONOSPACE;
SetStyle(style);
UpdateWindow();
}
BOOL CBottonTabCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// 将WM_NOTIFY消息转交给父窗口处理
GetParent()->SendMessage(WM_NOTIFY, wParam, lParam);
*pResult = 0;
return TRUE;
}
int CBottonTabCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
LOGFONT logFont;
ZeroMemory((void*)&logFont,sizeof(logFont));
wcscpy(logFont.lfFaceName,_T("宋体"));
logFont.lfHeight = -12;
logFont.lfWeight = 400;
logFont.lfCharSet = GB2312_CHARSET;
logFont.lfOutPrecision = 3;
logFont.lfClipPrecision = 2;
logFont.lfQuality = 1;
logFont.lfPitchAndFamily = 2;
m_font.CreateFontIndirect(&logFont);
SetFont(&m_font);
m_brush.CreateSolidBrush(RGB(255,255,255));
return 0;
}
void CBottonTabCtrl::OnDestroy()
{
CWnd::OnDestroy();
}
HBRUSH CBottonTabCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
wchar_t cTemp[20];
GetClassName(pWnd->GetSafeHwnd(),cTemp,sizeof(cTemp));
if (CString(cTemp)==_T("Edit"))
{
static HBRUSH hbrEdit = ::CreateSolidBrush(RGB(255, 255, 255));
pDC->SetBkColor(RGB(255, 255, 255));
pDC->SetTextColor(RGB(0, 0, 0));
return hbrEdit;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}