-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLabel.cpp
1359 lines (1164 loc) · 30.7 KB
/
Label.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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Label.cpp : implementation file
//
#include "stdafx.h"
#include "Label.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CLabel, CStatic)
//{{AFX_MSG_MAP(CLabel)
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
ON_WM_SYSCOLORCHANGE()
ON_WM_PAINT()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLabel Version 1.2
//
// From now on I'll try to keep a log of fixes and enhancements...
//
// The new feature were added due to the response of people.
// All I ask is to all you programmers out there, is if you add, fix or
// enhance this code, sent me a copy and I'll send the copy on to www.codeproject.com
//
// Happy Software Engineer :)
//
// New features include:
//
// A. Support for 3D Fonts
// B. Support for background transparency
// C. More comments provided
// D. If alignment is 'centered' and the window text is seperated by '\r\n'
// the will be centered accordingly - requested by someone @ nasa ;)
// E. Support for font rotation.
// F. Respond to System Color Change
// G. OnPaint improved performance - using Double Buffering Technique
//
// Thanks to:
// Mark McDowell - For suggestion on 'Increasing the flexibility of "hypertext" setting...'
// Erich Ruth - For suggestion on 'Font Rotation'
//
/////////////////////////////////////////////////////////////////////////////
// CLabel Version 1.3
//
// A. Added SS_LEFTNOWORDWRAP to include wordwrap
// B. Fix repainting problem
// C. Fix SetBkColor
// D. Added SS_CENTER
// Thanks to:
// Marius - Added styling problem.
// Azing Vondeling & Broker - Spotting painting Problem.
// Mel Stober - Back Color & SS_CENTER
//
/////////////////////////////////////////////////////////////////////////////
// CLabel Version 1.4
//
// A. Fix to transparency mode
// B. Added new SetText3DHiliteColor to change the 3D Font face color - default is white.
//
// Thanks to:
// michael.groeger - Spotting Transparency with other controls bug.
//
//
/////////////////////////////////////////////////////////////////////////////
// CLabel Version 1.5
//
// A. Sanity handle check
// B. Support Interface Charset
// C. Check compilition with _UNICODE
// D. Fix hyperlink feature
// E. Support default Dialog Font
// F. Inclusion of SS_OWNERDRAW via control creation and subclassing
// G. Modification to Text aligmnent code
// H. New background gradient fill function
//
// Thanks to:
// Steve Kowald - Using null handles
// Alan Chan - Supporting International Windows
// Dieter Fauth - Request for default Dialog font
// Herb Illfelder - Text Alignment code
//
/////////////////////////////////////////////////////////////////////////////
// CLabel Version 1.6
// Jeroen Roosendaal - SetFont suggestion
// Laurent - Spotting SelectObject bugs
// Bernie - Fix PreCreateWindow bug
// Jignesh I. Patel - Added expanded tabs feature
// Jim Farmelant - Fix SetText crash
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::CLabel
//
// Description: Default contructor
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel::CLabel()
{
m_crText = GetSysColor(COLOR_WINDOWTEXT);
// 1.1
m_hBackBrush = NULL;
m_crHiColor = 0;
m_crLoColor = 0;
m_bTimer = FALSE;
m_bState = FALSE;
m_bTransparent = FALSE;
m_Link = LinkNone;
m_hCursor = NULL;
m_Type = None;
m_bFont3d = FALSE;
m_bNotifyParent = FALSE;
m_bToolTips = FALSE;
m_bRotation = FALSE;
m_fillmode = Normal;
m_cr3DHiliteColor = RGB(255,255,255);
m_hwndBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::~CLabel
//
// Description:
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 15092000 1.5 Handle Check
//////////////////////////////////////////////////////////////////////////
CLabel::~CLabel()
{
// Clean up
m_font.DeleteObject();
::DeleteObject(m_hwndBrush);
// Stop Checking complaining
if (m_hBackBrush)
::DeleteObject(m_hBackBrush);
}
void CLabel::UpdateSurface()
{
CRect (rc);
GetWindowRect(rc);
RedrawWindow();
GetParent()->ScreenToClient(rc);
GetParent()->InvalidateRect(rc,TRUE);
GetParent()->UpdateWindow();
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::ReconstructFont
//
// Description: Helper function to build font after it was changed
//
// INPUTS:
//
// RETURNS:
//
// NOTES: PROTECTED
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
void CLabel::ReconstructFont()
{
m_font.DeleteObject();
BOOL bCreated = m_font.CreateFontIndirect(&m_lf);
ASSERT(bCreated);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::OnPaint
//
// Description: Handles all the drawing code for the label
//
// INPUTS:
//
// RETURNS:
//
// NOTES: Called by Windows... not by USER
// Probably needs tiding up a some point.
// Different states will require this code to be reworked.
//
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
// NT ALMOND 15092000 1.5 Handle Check
// NT ALMOND 15092000 1.5 Alignment mods
// NT ALMOND 15092000 1.5 Gradient Fill Mode
// NT ALMOND 02072002 1.6 Fill SelectObject bugs
// NT ALMOND 02072002 1.6 Added to expand tabs
//////////////////////////////////////////////////////////////////////////
void CLabel::OnPaint()
{
CPaintDC dc(this); // device context for painting
DWORD dwFlags = 0;
CRect rc;
GetClientRect(rc);
CString strText;
GetWindowText(strText);
CBitmap bmp;
///////////////////////////////////////////////////////
//
// Set up for double buffering...
//
CDC* pDCMem;
CBitmap* pOldBitmap = NULL;
if (!m_bTransparent)
{
pDCMem = new CDC;
pDCMem->CreateCompatibleDC(&dc);
bmp.CreateCompatibleBitmap(&dc,rc.Width(),rc.Height());
pOldBitmap = pDCMem->SelectObject(&bmp);
}
else
{
pDCMem = &dc;
}
UINT nMode = pDCMem->SetBkMode(TRANSPARENT);
COLORREF crText = pDCMem->SetTextColor(m_crText);
CFont *pOldFont = pDCMem->SelectObject(&m_font);
// Fill in backgound if not transparent
if (!m_bTransparent)
{
if (m_fillmode == Normal)
{
CBrush br;
if (m_hBackBrush != NULL)
br.Attach(m_hBackBrush);
else
br.Attach(m_hwndBrush);
pDCMem->FillRect(rc,&br);
br.Detach();
}
else // Gradient Fill
{
DrawGradientFill(pDCMem, &rc, m_crLoColor, m_crHiColor, 100);
}
}
// If the text is flashing turn the text color on
// then to the color of the window background.
LOGBRUSH lb;
ZeroMemory(&lb,sizeof(lb));
// Stop Checking complaining
if (m_hBackBrush)
::GetObject(m_hBackBrush,sizeof(lb),&lb);
// Something to do with flashing
if (!m_bState && m_Type == Text)
pDCMem->SetTextColor(lb.lbColor);
DWORD style = GetStyle();
switch (style & SS_TYPEMASK)
{
case SS_RIGHT:
dwFlags = DT_RIGHT | DT_WORDBREAK;
break;
case SS_CENTER:
dwFlags = SS_CENTER | DT_WORDBREAK;
break;
case SS_LEFTNOWORDWRAP:
dwFlags = DT_LEFT;
break;
default: // treat other types as left
case SS_LEFT:
dwFlags = DT_LEFT | DT_WORDBREAK;
break;
}
// Added to expand tabs...
if(strText.Find(_T('\t')) != -1)
dwFlags |= DT_EXPANDTABS;
// If the text centered make an assumtion that
// the will want to center verticly as well
if (style & SS_CENTERIMAGE)
{
dwFlags = DT_CENTER;
// Apply
if (strText.Find(_T("\r\n")) == -1)
{
dwFlags |= DT_VCENTER;
// And because DT_VCENTER only works with single lines
dwFlags |= DT_SINGLELINE;
}
}
//
// 3333 DDDDD
// 3 D D
// 33 D D E F X
// 3 D D
// 3333 DDDDD
//
//
if (m_bRotation)
{
int nAlign = pDCMem->SetTextAlign (TA_BASELINE);
CPoint pt;
GetViewportOrgEx (pDCMem->m_hDC,&pt) ;
SetViewportOrgEx (pDCMem->m_hDC,rc.Width() / 2, rc.Height() / 2, NULL) ;
pDCMem->TextOut (0, 0, strText) ;
SetViewportOrgEx (pDCMem->m_hDC,pt.x / 2, pt.y / 2, NULL) ;
pDCMem->SetTextAlign (nAlign);
}
else
{
pDCMem->DrawText(strText,rc,dwFlags);
if (m_bFont3d)
{
pDCMem->SetTextColor(m_cr3DHiliteColor);
if (m_3dType == Raised)
rc.OffsetRect(-1,-1);
else
rc.OffsetRect(1,1);
pDCMem->DrawText(strText,rc,dwFlags);
m_3dType;
}
}
// Restore DC's State
pDCMem->SetBkMode(nMode);
pDCMem->SelectObject(pOldFont);
pDCMem->SetTextColor(crText);
if (!m_bTransparent)
{
dc.BitBlt(0,0,rc.Width(),rc.Height(),pDCMem,0,0,SRCCOPY);
// continue DC restore
pDCMem->SelectObject ( pOldBitmap ) ;
delete pDCMem;
}
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::OnTimer
//
// Description: Used in conjunction with 'FLASH' functions
//
// INPUTS: Windows API
//
// RETURNS: Windows API
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
void CLabel::OnTimer(UINT nIDEvent)
{
m_bState = !m_bState;
UpdateSurface();
CStatic::OnTimer(nIDEvent);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::OnSetCursor
//
// Description: Used in conjunction with 'LINK' function
//
// INPUTS: Windows API
//
// RETURNS: Windows API
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
BOOL CLabel::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (m_hCursor)
{
::SetCursor(m_hCursor);
return TRUE;
}
return CStatic::OnSetCursor(pWnd, nHitTest, message);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::OnLButtonDown
//
// Description: Called when a link is click on
//
// INPUTS: Windows API
//
// RETURNS: Windows API
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 02072002 1.6 Added Mail support
//////////////////////////////////////////////////////////////////////////
void CLabel::OnLButtonDown(UINT nFlags, CPoint point)
{
if (!m_bNotifyParent) // Fix
{
CString strLink;
GetWindowText(strLink);
if (m_Link == HyperLink)
{
ShellExecute(NULL,_T("open"),m_sLink.IsEmpty() ? strLink : m_sLink,NULL,NULL,SW_SHOWNORMAL);
}
if (m_Link == MailLink)
{
strLink = _T("mailto:") + strLink;
ShellExecute( NULL, NULL, strLink, NULL, NULL, SW_SHOWNORMAL );
}
}
else
{
// To use notification in parent window
// Respond to a OnNotify in parent and disassemble the message
//
NMHDR nm;
nm.hwndFrom = GetSafeHwnd();
nm.idFrom = GetDlgCtrlID();
nm.code = NM_LINKCLICK;
GetParent()->SendMessage(WM_NOTIFY,nm.idFrom,(LPARAM) &nm);
}
CStatic::OnLButtonDown(nFlags, point);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// THE FUNCTIONS START HERE :----
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetText
//
// Description: Short cut to set window text - caption - label
//
// INPUTS: Text to use
//
// RETURNS: Reference to this
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26081998 1.0 Origin
// NT ALMOND 02072002 1.6 Crash Fix
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetText(const CString& strText)
{
if(IsWindow(this->GetSafeHwnd()))
{
SetWindowText(strText);
UpdateSurface();
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetTextColor
//
// Description: Sets the text color
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetTextColor(COLORREF crText)
{
m_crText = crText;
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFontBold
//
// Description: Sets the font ot bold
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFontBold(BOOL bBold)
{
m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFontUnderline
//
// Description: Sets font underline attribue
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFontUnderline(BOOL bSet)
{
m_lf.lfUnderline = bSet;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFontItalic
//
// Description: Sets font italic attribute
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFontItalic(BOOL bSet)
{
m_lf.lfItalic = bSet;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetSunken
//
// Description: Sets sunken effect on border
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetSunken(BOOL bSet)
{
if (!bSet)
ModifyStyleEx(WS_EX_STATICEDGE,0,SWP_DRAWFRAME);
else
ModifyStyleEx(0,WS_EX_STATICEDGE,SWP_DRAWFRAME);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetBorder
//
// Description: Toggles the border on/off
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetBorder(BOOL bSet)
{
if (!bSet)
ModifyStyle(WS_BORDER,0,SWP_DRAWFRAME);
else
ModifyStyle(0,WS_BORDER,SWP_DRAWFRAME);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFontSize
//
// Description: Sets the font size
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFontSize(int nSize)
{
CFont cf;
LOGFONT lf;
cf.CreatePointFont(nSize * 10, m_lf.lfFaceName);
cf.GetLogFont(&lf);
m_lf.lfHeight = lf.lfHeight;
m_lf.lfWidth = lf.lfWidth;
// nSize*=-1;
// m_lf.lfHeight = nSize;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetBkColor
//
// Description: Sets background color
//
// INPUTS: Colorref of background color
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetBkColor(COLORREF crBkgnd, COLORREF crBkgndHigh , BackFillMode mode)
{
m_crLoColor = crBkgnd;
m_crHiColor = crBkgndHigh;
m_fillmode = mode;
if (m_hBackBrush)
::DeleteObject(m_hBackBrush);
if (m_fillmode == Normal)
m_hBackBrush = ::CreateSolidBrush(crBkgnd);
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFontName
//
// Description: Sets the fonts face name
//
// INPUTS: String containing font name
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 15092000 1.5 Support internation windows
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFontName(const CString& strFont, BYTE byCharSet /* Default = ANSI_CHARSET */)
{
m_lf.lfCharSet = byCharSet;
_tcscpy(m_lf.lfFaceName,strFont);
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::FlashText
//
// Description: As the function states
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::FlashText(BOOL bActivate)
{
if (m_bTimer)
KillTimer(1);
if (bActivate)
{
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
m_Type = Text;
}
else
m_Type = None; // Fix
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::FlashBackground
//
// Description: As the function states
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::FlashBackground(BOOL bActivate)
{
if (m_bTimer)
KillTimer(1);
if (bActivate)
{
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
m_Type = Background;
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetLink
//
// Description: Indicates the string is a link
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 26/08/99 1.2 Added flexbility of
// Sending Click meessage to parent
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetLink(BOOL bLink,BOOL bNotifyParent)
{
if (bLink)
m_Link = HyperLink;
else
m_Link = LinkNone;
m_bNotifyParent = bNotifyParent;
if (m_Link != LinkNone)
ModifyStyle(0,SS_NOTIFY);
else
ModifyStyle(SS_NOTIFY,0);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetLinkCursor
//
// Description: Sets the internet browers link
//
// INPUTS: Handle of cursor
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetLinkCursor(HCURSOR hCursor)
{
m_hCursor = hCursor;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetTransparent
//
// Description: Sets the Label window to be transpaent
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetTransparent(BOOL bSet)
{
m_bTransparent = bSet;
ModifyStyleEx(0,WS_EX_TRANSPARENT); // Fix for transparency