forked from sabrogden/Ditto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGdipButton.cpp
716 lines (592 loc) · 18.9 KB
/
GdipButton.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
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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
//
// GdipButton.cpp : Version 1.0 - see article at CodeProject.com
//
// Author: Darren Sessions
//
//
// Description:
// GdipButton is a CButton derived control that uses GDI+
// to support alternate image formats
//
// History
// Version 1.0 - 2008 June 10
// - Initial public release
//
// License:
// This software is released under the Code Project Open License (CPOL),
// which may be found here: http://www.codeproject.com/info/eula.aspx
// You are free to use this software in any way you like, except that you
// may not sell this source code.
//
// This software is provided "as is" with no expressed or implied warranty.
// I accept no liability for any damage or loss of business that this
// software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "GdipButton.h"
#include "CGdiPlusBitmap.h"
#include "MemDC.h"
#include "CP_Main.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGdipButton
CGdipButton::CGdipButton()
{
m_pStdImage = NULL;
m_pAltImage = NULL;
m_bHaveBitmaps = FALSE;
m_bHaveAltImage = FALSE;
m_pCurBtn = NULL;
m_bIsDisabled = FALSE;
m_bIsToggle = FALSE;
m_bIsHovering = FALSE;
m_bIsTracking = FALSE;
m_nCurType = STD_TYPE;
m_pToolTip = NULL;
}
CGdipButton::~CGdipButton()
{
if(m_pStdImage) delete m_pStdImage;
if(m_pAltImage) delete m_pAltImage;
if(m_pToolTip) delete m_pToolTip;
}
BEGIN_MESSAGE_MAP(CGdipButton, CButton)
//{{AFX_MSG_MAP(CGdipButton)
ON_WM_DRAWITEM()
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR_REFLECT()
ON_WM_MOUSEMOVE()
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
ON_MESSAGE(WM_MOUSEHOVER, OnMouseHover)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CGdipButton::LoadStdImageDPI(int dpi, UINT id96, UINT id120, UINT id144, UINT id168, UINT id192, LPCTSTR pType, UINT id225, UINT id250, UINT id275, UINT id300, UINT id325, UINT id350)
{
BOOL ret = FALSE;
if (dpi >= 336 && id350 != 0)
{
ret = LoadStdImage(id350, pType);
}
else if (dpi >= 312 && id325 != 0)
{
ret = LoadStdImage(id325, pType);
}
else if (dpi >= 288 && id300 != 0)
{
ret = LoadStdImage(id300, pType);
}
else if (dpi >= 264 && id275 != 0)
{
ret = LoadStdImage(id275, pType);
}
else if (dpi >= 240 && id250 != 0)
{
ret = LoadStdImage(id250, pType);
}
else if (dpi >= 216 && id225 != 0)
{
ret = LoadStdImage(id225, pType);
}
else if (dpi >= 192)
{
ret = LoadStdImage(id192, pType);
}
else if (dpi >= 168)
{
ret = LoadStdImage(id168, pType);
}
else if (dpi >= 144)
{
ret = LoadStdImage(id144, pType);
}
else if (dpi >= 120)
{
ret = LoadStdImage(id120, pType);
}
else
{
ret = LoadStdImage(id96, pType);
}
return ret;
}
//=============================================================================
//
// LoadStdImage()
//
// Purpose: The LoadStdImage() Loads the image for the button. This
// function must be called at a minimum or the button wont do
// anything.
//
// Parameters:
// [IN] id
// resource id, one of the resources already imported with the
// resource editor, usually begins with IDR_
//
// [IN] pType
// pointer to string describing the resource type
//
// Returns: BOOL
// Non zero if successful, otherwise zero
//
//=============================================================================
BOOL CGdipButton::LoadStdImage(UINT id, LPCTSTR pType)
{
m_pStdImage = new CGdiPlusBitmapResource;
return m_pStdImage->Load(id, pType);
}
void CGdipButton::Reset()
{
delete m_pStdImage;
m_pStdImage = NULL;
delete m_pAltImage;
m_pAltImage = NULL;
delete m_pToolTip;
m_pToolTip = NULL;
m_bHaveBitmaps = FALSE;
m_bHaveAltImage = FALSE;
m_dcStd.DeleteDC();
m_dcStdP.DeleteDC();
m_dcStdH.DeleteDC();
m_dcBk.DeleteDC();
}
void CGdipButton::Test(CString c)
{
m_pStdImage = new CGdiPlusBitmapResource;
m_pStdImage->Loads(c);
}
//=============================================================================
//
// LoadAltImage()
//
// Purpose: The LoadAltImage() Loads the altername image for the button.
// This function call is optional
// Parameters:
// [IN] id
// resource id, one of the resources already imported with the
// resource editor, usually begins with IDR_
//
// [IN] pType
// pointer to string describing the resource type
//
// Returns: BOOL
// Non zero if successful, otherwise zero
//
//=============================================================================
BOOL CGdipButton::LoadAltImage(UINT id, LPCTSTR pType)
{
m_bHaveAltImage = TRUE;
m_pAltImage = new CGdiPlusBitmapResource;
return (m_pAltImage->Load(id, pType));
}
//=============================================================================
//
// The framework calls this member function when a child control is about to
// be drawn. All the bitmaps are created here on the first call. Every thing
// is done with a memory DC except the background, which get's it's information
// from the parent. The background is needed for transparent portions of PNG
// images. An always on top app (such as Task Manager) that is in the way can
// cause it to get an incorrect background. To avoid this, the parent should
// call the SetBkGnd function with a memory DC when it creates the background.
//
//=============================================================================
HBRUSH CGdipButton::CtlColor(CDC* pScreenDC, UINT nCtlColor)
{
if(!m_bHaveBitmaps)
{
if(!m_pStdImage)
{
return NULL; // Load the standard image with LoadStdImage()
}
CBitmap bmp, *pOldBitmap;
CRect rect;
GetClientRect(rect);
// do everything with mem dc
CMemDCEx pDC(pScreenDC, rect);
Gdiplus::Graphics graphics(pDC->m_hDC);
// background
if (m_dcBk.m_hDC == NULL)
{
CRect rect1;
CClientDC clDC(GetParent());
GetWindowRect(rect1);
GetParent()->ScreenToClient(rect1);
m_dcBk.CreateCompatibleDC(&clDC);
bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
pOldBitmap = m_dcBk.SelectObject(&bmp);
m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
bmp.DeleteObject();
}
// standard image
if (m_dcStd.m_hDC == NULL)
{
PaintBk(pDC);
/*graphics.DrawImage(*m_pStdImage, 0, 0);
m_dcStd.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcStd.SelectObject(&bmp);
m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();*/
float width = (float)m_pStdImage->m_pBitmap->GetWidth();
float height = (float)m_pStdImage->m_pBitmap->GetHeight();
RectF grect; grect.X = 0, grect.Y = 0; grect.Width = width; grect.Height = height;
graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel);
m_dcStd.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcStd.SelectObject(&bmp);
m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
// standard image pressed
if (m_dcStdP.m_hDC == NULL)
{
PaintBk(pDC);
//graphics.DrawImage(*m_pStdImage, 1, 1);
//m_dcStdP.CreateCompatibleDC(pDC);
//bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
//pOldBitmap = m_dcStdP.SelectObject(&bmp);
//m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
//bmp.DeleteObject();
float width = (float)m_pStdImage->m_pBitmap->GetWidth();
float height = (float)m_pStdImage->m_pBitmap->GetHeight();
RectF grect; grect.X = 0, grect.Y = 0; grect.Width = width; grect.Height = height;
graphics.DrawImage(*m_pStdImage, grect, -1, -1, width, height, UnitPixel);
m_dcStdP.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcStdP.SelectObject(&bmp);
m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
}
// standard image hot
if(m_dcStdH.m_hDC == NULL)
{
PaintBk(pDC);
ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.05f, 0.05f, 0.05f, 0.00f, 1.00f };
ImageAttributes ia;
ia.SetColorMatrix(&HotMat);
float width = (float)m_pStdImage->m_pBitmap->GetWidth();
float height = (float)m_pStdImage->m_pBitmap->GetHeight();
RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;
graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);
m_dcStdH.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcStdH.SelectObject(&bmp);
m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
}
// grayscale image
if(m_dcGS.m_hDC == NULL)
{
PaintBk(pDC);
ColorMatrix GrayMat = { 0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.00f, 0.00f, 0.00f, 0.00f, 1.00f };
ImageAttributes ia;
ia.SetColorMatrix(&GrayMat);
float width = (float)m_pStdImage->m_pBitmap->GetWidth();
float height = (float)m_pStdImage->m_pBitmap->GetHeight();
RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;
graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);
m_dcGS.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcGS.SelectObject(&bmp);
m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
}
}
// alternate image
if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
{
PaintBk(pDC);
graphics.DrawImage(*m_pAltImage, 0, 0);
m_dcAlt.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcAlt.SelectObject(&bmp);
m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
// alternate image pressed
if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
{
PaintBk(pDC);
graphics.DrawImage(*m_pAltImage, 1, 1);
m_dcAltP.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcAltP.SelectObject(&bmp);
m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
}
// alternate image hot
if(m_dcAltH.m_hDC == NULL)
{
PaintBk(pDC);
ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.05f, 0.05f, 0.05f, 0.00f, 1.00f };
ImageAttributes ia;
ia.SetColorMatrix(&HotMat);
float width = (float)m_pStdImage->m_pBitmap->GetWidth();
float height = (float)m_pStdImage->m_pBitmap->GetHeight();
RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;
graphics.DrawImage(*m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);
m_dcAltH.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcAltH.SelectObject(&bmp);
m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
bmp.DeleteObject();
}
}
if(m_pCurBtn == NULL)
{
m_pCurBtn = &m_dcStd;
}
m_bHaveBitmaps = TRUE;
}
return NULL;
}
//=============================================================================
// paint the background
//=============================================================================
void CGdipButton::PaintBk(CDC *pDC)
{
CRect rect;
GetClientRect(rect);
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY);
}
//=============================================================================
// paint the bitmap currently pointed to with m_pCurBtn
//=============================================================================
void CGdipButton::PaintBtn(CDC *pDC)
{
CRect rect;
GetClientRect(rect);
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_pCurBtn, 0, 0, SRCCOPY);
}
//=============================================================================
// enables the toggle mode
// returns if it doesn't have the alternate image
//=============================================================================
void CGdipButton::EnableToggle(BOOL bEnable)
{
if(!m_bHaveAltImage) return;
m_bIsToggle = bEnable;
// this actually makes it start in the std state since toggle is called before paint
if(bEnable) m_pCurBtn = &m_dcAlt;
else m_pCurBtn = &m_dcStd;
}
//=============================================================================
// sets the image type and disabled state then repaints
//=============================================================================
void CGdipButton::SetImage(int type)
{
m_nCurType = type;
(type == DIS_TYPE) ? m_bIsDisabled = TRUE : m_bIsDisabled = FALSE;
Invalidate();
}
//=============================================================================
// set the control to owner draw
//=============================================================================
void CGdipButton::PreSubclassWindow()
{
// Set control to owner draw
ModifyStyle(0, BS_OWNERDRAW, SWP_FRAMECHANGED);
CButton::PreSubclassWindow();
}
//=============================================================================
// disable double click
//=============================================================================
BOOL CGdipButton::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_LBUTTONDBLCLK)
pMsg->message = WM_LBUTTONDOWN;
if (m_pToolTip != NULL)
{
if (::IsWindow(m_pToolTip->m_hWnd))
{
m_pToolTip->RelayEvent(pMsg);
}
}
return CButton::PreTranslateMessage(pMsg);
}
//=============================================================================
// overide the erase function
//=============================================================================
BOOL CGdipButton::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
//=============================================================================
// Paint the button depending on the state of the mouse
//=============================================================================
void CGdipButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
// handle disabled state
if(m_bIsDisabled)
{
m_pCurBtn = &m_dcGS;
PaintBtn(pDC);
return;
}
BOOL bIsPressed = (lpDIS->itemState & ODS_SELECTED);
// handle toggle button
if(m_bIsToggle && bIsPressed)
{
(m_nCurType == STD_TYPE) ? m_nCurType = ALT_TYPE : m_nCurType = STD_TYPE;
}
if(bIsPressed)
{
if(m_nCurType == STD_TYPE)
m_pCurBtn = &m_dcStdP;
else
m_pCurBtn = &m_dcAltP;
}
else if(m_bIsHovering)
{
if(m_nCurType == STD_TYPE)
m_pCurBtn = &m_dcStdH;
else
m_pCurBtn = &m_dcAltH;
}
else
{
if(m_nCurType == STD_TYPE)
m_pCurBtn = &m_dcStd;
else
m_pCurBtn = &m_dcAlt;
}
// paint the button
PaintBtn(pDC);
}
//=============================================================================
LRESULT CGdipButton::OnMouseHover(WPARAM wparam, LPARAM lparam)
//=============================================================================
{
m_bIsHovering = TRUE;
Invalidate();
DeleteToolTip();
// Create a new Tooltip with new Button Size and Location
SetToolTipText(m_tooltext);
if (m_pToolTip != NULL)
{
if (::IsWindow(m_pToolTip->m_hWnd))
{
//Display ToolTip
m_pToolTip->Update();
}
}
return 0;
}
//=============================================================================
LRESULT CGdipButton::OnMouseLeave(WPARAM wparam, LPARAM lparam)
//=============================================================================
{
m_bIsTracking = FALSE;
m_bIsHovering = FALSE;
Invalidate();
return 0;
}
//=============================================================================
void CGdipButton::OnMouseMove(UINT nFlags, CPoint point)
//=============================================================================
{
if (!m_bIsTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE|TME_HOVER;
tme.dwHoverTime = 1;
m_bIsTracking = _TrackMouseEvent(&tme);
}
CButton::OnMouseMove(nFlags, point);
}
//=============================================================================
//
// Call this member function with a memory DC from the code that paints
// the parents background. Passing the screen DC defeats the purpose of
// using this function.
//
//=============================================================================
void CGdipButton::SetBkGnd(CDC* pDC)
{
CRect rect, rectS;
CBitmap bmp, *pOldBitmap;
GetClientRect(rect);
GetWindowRect(rectS);
GetParent()->ScreenToClient(rectS);
m_dcBk.DeleteDC();
m_dcBk.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
pOldBitmap = m_dcBk.SelectObject(&bmp);
m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, rectS.left, rectS.top, SRCCOPY);
bmp.DeleteObject();
}
//=============================================================================
// Set the tooltip with a string resource
//=============================================================================
void CGdipButton::SetToolTipText(UINT nId, BOOL bActivate)
{
// load string resource
m_tooltext.LoadString(nId);
// If string resource is not empty
if (m_tooltext.IsEmpty() == FALSE)
{
SetToolTipText(m_tooltext, bActivate);
}
}
//=============================================================================
// Set the tooltip with a CString
//=============================================================================
void CGdipButton::SetToolTipText(CString spText, BOOL bActivate)
{
// We cannot accept NULL pointer
if (spText.IsEmpty()) return;
// Initialize ToolTip
InitToolTip();
m_tooltext = spText;
// If there is no tooltip defined then add it
if (m_pToolTip->GetToolCount() == 0)
{
CRect rectBtn;
GetClientRect(rectBtn);
m_pToolTip->AddTool(this, m_tooltext, rectBtn, 1);
}
// Set text for tooltip
m_pToolTip->UpdateTipText(m_tooltext, this, 1);
m_pToolTip->SetDelayTime(2000);
m_pToolTip->Activate(bActivate);
}
//=============================================================================
void CGdipButton::InitToolTip()
//=============================================================================
{
if (m_pToolTip == NULL)
{
m_pToolTip = new CToolTipCtrl;
// Create ToolTip control
m_pToolTip->Create(this);
m_pToolTip->Activate(TRUE);
}
}
//=============================================================================
void CGdipButton::DeleteToolTip()
//=============================================================================
{
// Destroy Tooltip incase the size of the button has changed.
if (m_pToolTip != NULL)
{
delete m_pToolTip;
m_pToolTip = NULL;
}
}