summaryrefslogtreecommitdiffstats
path: root/mmc_updater/depends/win32cpp/stdcontrols.h
blob: b362f07bff60b9b280e257365e3e8b0181fb3fb0 (plain)
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
// Win32++   Version 7.2
// Released: 5th AUgust 2011
//
//      David Nash
//      email: dnash@bigpond.net.au
//      url: https://sourceforge.net/projects/win32-framework
//
//
// Copyright (c) 2005-2011  David Nash
//
// Permission is hereby granted, free of charge, to
// any person obtaining a copy of this software and
// associated documentation files (the "Software"),
// to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom
// the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
//
////////////////////////////////////////////////////////


////////////////////////////////////////////////////////
// stdcontrols.h
//  Declaration of the CButton, CEdit, CListBox and CStatic classes

// The Button, Edit, ListBox and Static controls are often referred to 
// as "standard controls". These set of older controls were originally 
// developed for Win16 operating systems (Windows 3.1 and 3.11). They use an
// older form of notification, and send their notifications via a WM_COMMAND
// message. Newer controls send their notifications via a WM_NOTIFY message.


#ifndef _WIN32XX_STDCONTROLS_H_
#define _WIN32XX_STDCONTROLS_H_

#include "wincore.h"


namespace Win32xx
{
	class CButton : public CWnd
	{
	public:
		CButton() {}
		virtual ~CButton() {}

		// Attributes
		HBITMAP GetBitmap() const;
		UINT GetButtonStyle() const;
		int GetCheck() const;
		HCURSOR GetCursor() const;
		HICON GetIcon() const;
		UINT GetState() const;
		HBITMAP SetBitmap(HBITMAP hBitmap) const;
		void SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const;
		void SetCheck(int nCheckState) const;
		HCURSOR SetCursor(HCURSOR hCursor) const;
		HICON SetIcon(HICON hIcon) const;
		void SetState(BOOL bHighlight) const;

	protected:
		// Overridables
		virtual void PreCreate(CREATESTRUCT& cs);
	};

	class CEdit : public CWnd
	{
	public:
		// Construction
		CEdit() {}
		virtual ~CEdit() {}

		// Attributes
		BOOL CanUndo() const;
		int CharFromPos(CPoint pt) const;
		int GetFirstVisibleLine() const;
		HLOCAL GetHandle() const;
		UINT GetLimitText() const;
		int GetLine(int nIndex, LPTSTR lpszBuffer) const;
		int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
		int GetLineCount() const;
		DWORD GetMargins() const;
		BOOL GetModify() const;
		TCHAR GetPasswordChar() const;
		void GetRect(LPRECT lpRect) const;
		void GetSel(int& nStartChar, int& nEndChar) const;
		DWORD GetSel() const;
		CPoint PosFromChar(UINT nChar) const;
		void SetHandle(HLOCAL hBuffer) const;
		void SetLimitText(UINT nMax) const;
		void SetMargins(UINT nLeft, UINT nRight) const;
		void SetModify(BOOL bModified = TRUE) const;

		// Operations
		void EmptyUndoBuffer() const;
		BOOL FmtLines(BOOL bAddEOL) const;
		void LimitText(int nChars = 0) const;
		int LineFromChar(int nIndex = -1) const;
		int LineIndex(int nLine = -1) const;
		int LineLength(int nLine = -1) const;
		void LineScroll(int nLines, int nChars = 0) const;
		void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const;
		void SetPasswordChar(TCHAR ch) const;
		BOOL SetReadOnly(BOOL bReadOnly = TRUE) const;
		void SetRect(LPCRECT lpRect) const;
		void SetRectNP(LPCRECT lpRect) const;
		void SetSel(DWORD dwSelection, BOOL bNoScroll) const;
		void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const;
		BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;
		BOOL SetTabStops() const;
		BOOL SetTabStops(const int& cxEachStop) const;

		//Clipboard Operations
		void Clear() const;
		void Copy() const;
		void Cut() const;
		void Paste() const;
		void Undo() const;

	protected:
		// Overridables
		virtual void PreRegisterClass(WNDCLASS &wc);
	};

	class CListBox : public CWnd
	{
	public:
		CListBox() {}
		virtual ~CListBox() {}

		// General Operations
		int  GetCount() const;
		int  GetHorizontalExtent() const;
		DWORD GetItemData(int nIndex) const;
		void* GetItemDataPtr(int nIndex) const;
		int  GetItemHeight(int nIndex) const;
		int  GetItemRect(int nIndex, LPRECT lpRect) const;
		LCID GetLocale() const;
		int  GetSel(int nIndex) const;
		int  GetText(int nIndex, LPTSTR lpszBuffer) const;
		int  GetTextLen(int nIndex) const;
		int  GetTopIndex() const;
		UINT ItemFromPoint(CPoint pt, BOOL& bOutside ) const;
		void SetColumnWidth(int cxWidth) const;
		void SetHorizontalExtent(int cxExtent) const;
		int  SetItemData(int nIndex, DWORD dwItemData) const;
		int  SetItemDataPtr(int nIndex, void* pData) const;
		int  SetItemHeight(int nIndex, UINT cyItemHeight) const;
		LCID SetLocale(LCID nNewLocale) const;
		BOOL SetTabStops(int nTabStops, LPINT rgTabStops) const;
		void SetTabStops() const;
		BOOL SetTabStops(const int& cxEachStop) const;
		int  SetTopIndex(int nIndex) const;

		// Single-Selection Operations
		int  GetCurSel() const;
		int  SetCurSel(int nSelect) const;

		// Multiple-Selection Operations
		int  GetAnchorIndex() const;
		int  GetCaretIndex() const;
		int  GetSelCount() const;
		int  GetSelItems(int nMaxItems, LPINT rgIndex) const;
		int  SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const;
		void SetAnchorIndex(int nIndex) const;
		int  SetCaretIndex(int nIndex, BOOL bScroll) const;
		int  SetSel(int nIndex, BOOL bSelect) const;

		// String Operations
		int  AddString(LPCTSTR lpszItem) const;
		int  DeleteString(UINT nIndex) const;
		int  Dir(UINT attr, LPCTSTR lpszWildCard) const;
		int  FindString(int nStartAfter, LPCTSTR lpszItem) const;
		int  FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
		int  InsertString(int nIndex, LPCTSTR lpszItem) const;
		void ResetContent() const;
		int  SelectString(int nStartAfter, LPCTSTR lpszItem) const;

	protected:
		// Overridables
		virtual void PreRegisterClass(WNDCLASS &wc);
	};

	class CStatic : public CWnd
	{
	public:
		CStatic() {}
		virtual ~CStatic() {}

		// Operations
		HBITMAP  GetBitmap() const;
		HCURSOR GetCursor() const;
		HENHMETAFILE GetEnhMetaFile() const;
		HICON  GetIcon() const;
		HBITMAP SetBitmap(HBITMAP hBitmap) const;
		HCURSOR SetCursor(HCURSOR hCursor) const;
		HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile) const;
		HICON SetIcon(HICON hIcon) const;

	protected:
		// Overridables
		virtual void PreRegisterClass(WNDCLASS &wc);

	};

}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


namespace Win32xx
{

	////////////////////////////////////////
	// Definitions for the CButton class
	//
	inline HBITMAP CButton::GetBitmap() const
	// returns the handle to the bitmap associated with the button
	{
		assert(::IsWindow(m_hWnd));
		return (HBITMAP)SendMessage(BM_GETIMAGE, IMAGE_BITMAP, 0);
	}

	inline UINT CButton::GetButtonStyle() const
	// returns the style of the button
	{
		assert(::IsWindow(m_hWnd));
		return (UINT)GetWindowLongPtr(GWL_STYLE) & 0xff;
	}

	inline int CButton::GetCheck() const
	// returns the check state of the button
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(BM_GETCHECK, 0, 0);
	}

	inline HCURSOR CButton::GetCursor() const
	// returns the handle to the cursor associated withe the button
	{
		assert(::IsWindow(m_hWnd));
		return (HCURSOR)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_CURSOR, 0L);
	}

	inline HICON CButton::GetIcon() const
	// returns the handle to the icon associated withe the button
	{
		assert(::IsWindow(m_hWnd));
		return (HICON)SendMessage(BM_GETIMAGE, IMAGE_ICON, 0);
	}

	inline UINT CButton::GetState() const
	// returns the state of the button
	{
		assert(::IsWindow(m_hWnd));
		return (UINT)SendMessage(BM_GETSTATE, 0, 0);
	}

	inline HBITMAP CButton::SetBitmap(HBITMAP hBitmap) const
	// sets the bitmap associated with the button
	{
		assert(::IsWindow(m_hWnd));
		return (HBITMAP)SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
	}

	inline void CButton::SetButtonStyle(DWORD dwStyle, BOOL bRedraw) const
	// sets the button style
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(BM_SETSTYLE, dwStyle, bRedraw);
	}

	inline void CButton::SetCheck(int nCheckState) const
	// sets the button check state
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(BM_SETCHECK, nCheckState, 0);
	}

	inline HCURSOR CButton::SetCursor(HCURSOR hCursor) const
	// sets the cursor associated with the button
	{
		assert(::IsWindow(m_hWnd));
		return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
	}

	inline HICON CButton::SetIcon(HICON hIcon) const
	// sets the icon associated with the button
	{
		assert(::IsWindow(m_hWnd));
		return (HICON)SendMessage( BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
	}

	inline void CButton::SetState(BOOL bHighlight) const
	// sets the button state
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(BM_SETSTATE, bHighlight, 0);
	}

	inline void CButton::PreCreate(CREATESTRUCT& cs)
	{
		cs.lpszClass = _T("Button");
	}


	////////////////////////////////////////
	// Definitions for the CEdit class
	//
	inline BOOL CEdit::CanUndo() const
	// Returns TRUE if the edit control operation can be undone.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(EM_CANUNDO, 0, 0);
	}

	inline int CEdit::CharFromPos(CPoint pt) const
	// Returns the character index and line index of the character nearest the specified point.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));
	}

	inline int CEdit::GetFirstVisibleLine() const
	// Returns the zero-based index of the first visible character in a single-line edit control 
	//  or the zero-based index of the uppermost visible line in a multiline edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0);
	}

	inline HLOCAL CEdit::GetHandle() const
	// Returns a handle identifying the buffer containing the multiline edit control's text. 
	//  It is not processed by single-line edit controls.
	{
		assert(::IsWindow(m_hWnd));
		return (HLOCAL)SendMessage(EM_GETHANDLE, 0, 0);
	}

	inline UINT CEdit::GetLimitText() const
	// Returns the current text limit, in characters.
	{
		assert(::IsWindow(m_hWnd));
		return (UINT)SendMessage(EM_GETLIMITTEXT, 0, 0);
	}

	inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer) const
	// Copies characters to a buffer and returns the number of characters copied.
	{
		assert(::IsWindow(m_hWnd));
		return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
	}

	inline int CEdit::GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
	// Copies characters to a buffer and returns the number of characters copied.
	{
		assert(::IsWindow(m_hWnd));
		*(LPWORD)lpszBuffer = (WORD)nMaxLength;
		return (int)SendMessage(EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
	}

	inline int CEdit::GetLineCount() const
	// Returns the number of lines in the edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_GETLINECOUNT, 0, 0);
	}

	inline DWORD CEdit::GetMargins() const
	// Returns the widths of the left and right margins.
	{
		assert(::IsWindow(m_hWnd));
		return (DWORD)SendMessage(EM_GETMARGINS, 0, 0);
	}

	inline BOOL CEdit::GetModify() const
	// Returns a flag indicating whether the content of an edit control has been modified.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(EM_GETMODIFY, 0, 0);
	}

	inline TCHAR CEdit::GetPasswordChar() const
	// Returns the character that edit controls use in conjunction with the ES_PASSWORD style.
	{
		assert(::IsWindow(m_hWnd));
		return (TCHAR)SendMessage(EM_GETPASSWORDCHAR, 0, 0);
	}

	inline void CEdit::GetRect(LPRECT lpRect) const
	// Returns the coordinates of the formatting rectangle in an edit control.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_GETRECT, 0, (LPARAM)lpRect);
	}

	inline void CEdit::GetSel(int& nStartChar, int& nEndChar) const
	// Returns the starting and ending character positions of the current selection in the edit control.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_GETSEL, (WPARAM)&nStartChar,(LPARAM)&nEndChar);
	}

	inline DWORD CEdit::GetSel() const
	// Returns the starting and ending character positions of the current selection in the edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (DWORD)SendMessage(EM_GETSEL, 0, 0);
	}

	inline CPoint CEdit::PosFromChar(UINT nChar) const
	// Returns the client coordinates of the specified character.
	{
		assert(::IsWindow(m_hWnd));
		return CPoint( (DWORD)SendMessage(EM_POSFROMCHAR, nChar, 0));
	}

	inline void CEdit::SetHandle(HLOCAL hBuffer) const
	// Sets a handle to the memory used as a text buffer, empties the undo buffer, 
	//  resets the scroll positions to zero, and redraws the window.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETHANDLE, (WPARAM)hBuffer, 0);
	}

	inline void CEdit::SetLimitText(UINT nMax) const
	// Sets the maximum number of characters the user may enter in the edit control.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETLIMITTEXT, (WPARAM)nMax, 0);
	}

	inline void CEdit::SetMargins(UINT nLeft, UINT nRight) const
	// Sets the widths of the left and right margins, and redraws the edit control to reflect the new margins.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));
	}

	inline void CEdit::SetModify(BOOL bModified) const
	// Sets or clears the modification flag to indicate whether the edit control has been modified.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETMODIFY, bModified, 0);
	}

	inline void CEdit::EmptyUndoBuffer() const
	// Empties the undo buffer and sets the undo flag retrieved by the EM_CANUNDO message to FALSE.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_EMPTYUNDOBUFFER, 0, 0);
	}

	inline BOOL CEdit::FmtLines(BOOL bAddEOL) const
	// Adds or removes soft line-break characters (two carriage returns and a line feed) to the ends of wrapped lines 
	//  in a multiline edit control. It is not processed by single-line edit controls.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(EM_FMTLINES, bAddEOL, 0);
	}

	inline void CEdit::LimitText(int nChars) const
	// Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs, 
	//  that the user can type into the edit control.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_LIMITTEXT, nChars, 0);
	}

	inline int CEdit::LineFromChar(int nIndex) const
	// Returns the zero-based number of the line in a multiline edit control that contains a specified character index.
	//  This message is the reverse of the EM_LINEINDEX message.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_LINEFROMCHAR, (WPARAM)nIndex, 0);
	}

	inline int CEdit::LineIndex(int nLine) const
	// Returns the character of a line in a multiline edit control. 
	// This message is the reverse of the EM_LINEFROMCHAR message
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_LINEINDEX, (WPARAM)nLine, 0);
	}

	inline int CEdit::LineLength(int nLine) const
	// Returns the length, in characters, of a single-line edit control. In a multiline edit control, 
	//	returns the length, in characters, of a specified line.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(EM_LINELENGTH, (WPARAM)nLine, 0);
	}

	inline void CEdit::LineScroll(int nLines, int nChars) const
	// Scrolls the text vertically in a single-line edit control or horizontally in a multiline edit control.
	{
		assert(::IsWindow(m_hWnd)); 
		SendMessage(EM_LINESCROLL, (WPARAM)nChars, (LPARAM)nLines);
	}

	inline void CEdit::ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const
	// Replaces the current selection with the text in an application-supplied buffer, sends the parent window 
	//  EN_UPDATE and EN_CHANGE messages, and updates the undo buffer.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
	}

	inline void CEdit::SetPasswordChar(TCHAR ch) const
	// Defines the character that edit controls use in conjunction with the ES_PASSWORD style.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETPASSWORDCHAR, ch, 0);
	}

	inline BOOL CEdit::SetReadOnly(BOOL bReadOnly) const
	// Sets or removes the read-only style (ES_READONLY) in an edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(EM_SETREADONLY, bReadOnly, 0);
	}

	inline void CEdit::SetRect(LPCRECT lpRect) const
	// Sets the formatting rectangle for the multiline edit control and redraws the window.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETRECT, 0, (LPARAM)lpRect);
	}

	inline void CEdit::SetRectNP(LPCRECT lpRect) const
	// Sets the formatting rectangle for the multiline edit control but does not redraw the window.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETRECTNP, 0, (LPARAM)lpRect);
	}

	inline void CEdit::SetSel(DWORD dwSelection, BOOL bNoScroll) const
	// Selects a range of characters in the edit control by setting the starting and ending positions to be selected.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
		if (!bNoScroll)
			SendMessage(EM_SCROLLCARET, 0, 0);
	}

	inline void CEdit::SetSel(int nStartChar, int nEndChar, BOOL bNoScroll) const
	// Selects a range of characters in the edit control by setting the starting and ending positions to be selected.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
		if (!bNoScroll)
			SendMessage(EM_SCROLLCARET, 0, 0);
	}

	inline BOOL CEdit::SetTabStops(int nTabStops, LPINT rgTabStops) const
	// Sets tab-stop positions in the multiline edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
	}

	inline BOOL CEdit::SetTabStops() const
	// Sets tab-stop positions in the multiline edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage( EM_SETTABSTOPS, 0, 0);
	}

	inline BOOL CEdit::SetTabStops(const int& cxEachStop) const
	// Sets tab-stop positions in the multiline edit control.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
	}

	inline void CEdit::Clear() const
	// Clears the current selection, if any, in an edit control.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(WM_CLEAR, 0, 0);
	}

	inline void CEdit::Copy() const
	// Copies text to the clipboard unless the style is ES_PASSWORD, in which case the message returns zero.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(WM_COPY,  0, 0);
	}

	inline void CEdit::Cut() const
	// Cuts the selection to the clipboard, or deletes the character to the left of the cursor if there is no selection.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(WM_CUT,   0, 0);
	}

	inline void CEdit::Paste() const
	// Pastes text from the clipboard into the edit control window at the caret position.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(WM_PASTE, 0, 0);
	}

	inline void CEdit::Undo() const
	// Removes any text that was just inserted or inserts any deleted characters and sets the selection to the inserted text.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(EM_UNDO,  0, 0);
	}

	inline void CEdit::PreRegisterClass(WNDCLASS &wc)
	{
		// Set the Window Class
		wc.lpszClassName =  _T("Edit");
	}


	////////////////////////////////////////
	// Definitions for the CListbox class
	//
	inline int CListBox::GetCount() const
	// Returns the number of items in the list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETCOUNT, 0, 0);
	}

	inline int CListBox::GetHorizontalExtent() const
	// Returns the scrollable width, in pixels, of a list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETHORIZONTALEXTENT,	0, 0);
	}

	inline DWORD CListBox::GetItemData(int nIndex) const
	// Returns the value associated with the specified item.
	{
		assert(::IsWindow(m_hWnd));
		return (DWORD)SendMessage(LB_GETITEMDATA, nIndex, 0);
	}

	inline void* CListBox::GetItemDataPtr(int nIndex) const
	// Returns the value associated with the specified item.
	{
		assert(::IsWindow(m_hWnd));
		return (LPVOID)SendMessage(LB_GETITEMDATA, nIndex, 0);
	}

	inline int CListBox::GetItemHeight(int nIndex) const
	// Returns the height, in pixels, of an item in a list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETITEMHEIGHT, nIndex, 0L);
	}

	inline int CListBox::GetItemRect(int nIndex, LPRECT lpRect) const
	// Retrieves the client coordinates of the specified list box item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETITEMRECT, nIndex, (LPARAM)lpRect);
	}

	inline LCID CListBox::GetLocale() const
	// Retrieves the locale of the list box. The high-order word contains the country/region code 
	//  and the low-order word contains the language identifier.
	{
		assert(::IsWindow(m_hWnd));
		return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0);
	}

	inline int CListBox::GetSel(int nIndex) const
	// Returns the selection state of a list box item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETSEL, nIndex, 0);
	}

	inline int CListBox::GetText(int nIndex, LPTSTR lpszBuffer) const
	// Retrieves the string associated with a specified item and the length of the string.
	{
		assert(::IsWindow(m_hWnd));
		return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);
	}

	inline int CListBox::GetTextLen(int nIndex) const
	// Returns the length, in characters, of the string associated with a specified item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage( LB_GETTEXTLEN, nIndex, 0);
	}

	inline int CListBox::GetTopIndex() const
	// Returns the index of the first visible item in a list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETTOPINDEX, 0, 0);
	}

	inline UINT CListBox::ItemFromPoint(CPoint pt, BOOL& bOutside) const
	// Retrieves the zero-based index of the item nearest the specified point in a list box.
	{
		assert(::IsWindow(m_hWnd));
		DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
		bOutside = !!HIWORD(dw);
		return LOWORD(dw);
	}

	inline void CListBox::SetColumnWidth(int cxWidth) const
	// Sets the width, in pixels, of all columns in a list box.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(LB_SETCOLUMNWIDTH, cxWidth, 0);
	}

	inline void CListBox::SetHorizontalExtent(int cxExtent) const
	// Sets the scrollable width, in pixels, of a list box.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(LB_SETHORIZONTALEXTENT, cxExtent, 0);
	}

	inline int CListBox::SetItemData(int nIndex, DWORD dwItemData) const
	// Associates a value with a list box item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
	}

	inline int CListBox::SetItemDataPtr(int nIndex, void* pData) const
	// Associates a value with a list box item.
	{
		assert(::IsWindow(m_hWnd));
		return SetItemData(nIndex, (DWORD)(DWORD_PTR)pData);
	}

	inline int CListBox::SetItemHeight(int nIndex, UINT cyItemHeight) const
	// Sets the height, in pixels, of an item or items in a list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
	}

	inline LCID CListBox::SetLocale(LCID nNewLocale) const
	// Sets the locale of a list box and returns the previous locale identifier.
	{
		assert(::IsWindow(m_hWnd));
		return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0);
	}

	inline BOOL CListBox::SetTabStops(int nTabStops, LPINT rgTabStops) const
	// Sets the tab stops to those specified in a specified array.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
	}

	inline void CListBox::SetTabStops() const
	// Sets the tab stops to those specified in a specified array.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(LB_SETTABSTOPS, 0, 0);
	}

	inline BOOL CListBox::SetTabStops(const int& cxEachStop) const
	// Sets the tab stops to those specified in a specified array.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
	}

	inline int CListBox::SetTopIndex(int nIndex) const
	// Scrolls the list box so the specified item is at the top of the visible range.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETTOPINDEX, nIndex, 0);
	}

	inline int CListBox::GetCurSel() const
	// Returns the index of the currently selected item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETCURSEL, 0, 0);
	}

	inline int CListBox::SetCurSel(int nSelect) const
	// Selects a specified list box item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETCURSEL, nSelect, 0);
	}

	inline int CListBox::GetAnchorIndex() const
	// Returns the index of the item that the mouse last selected.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETANCHORINDEX, 0, 0);
	}

	inline int CListBox::GetCaretIndex() const
	// Returns the index of the item that has the focus rectangle.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETCARETINDEX, 0, 0L);
	}

	inline int CListBox::GetSelCount() const
	// Returns the number of selected items in a multiple-selection list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETSELCOUNT, 0, 0);
	}

	inline int CListBox::GetSelItems(int nMaxItems, LPINT rgIndex) const
	// Creates an array of the indexes of all selected items in a multiple-selection list box 
	//  and returns the total number of selected items.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);
	}

	inline int CListBox::SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem) const
	// Selects a specified range of items in a list box.
	{
		assert(::IsWindow(m_hWnd));
		if (bSelect)
			return (int)SendMessage(LB_SELITEMRANGEEX, nFirstItem, nLastItem);
		else
			return (int)SendMessage(LB_SELITEMRANGEEX, nLastItem, nFirstItem);
	}

	inline void CListBox::SetAnchorIndex(int nIndex) const
	// Sets the item that the mouse last selected to a specified item.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(LB_SETANCHORINDEX, nIndex, 0);
	}

	inline int CListBox::SetCaretIndex(int nIndex, BOOL bScroll) const
	// Sets the focus rectangle to a specified list box item.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));
	}

	inline int CListBox::SetSel(int nIndex, BOOL bSelect) const
	// Selects an item in a multiple-selection list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_SETSEL, bSelect, nIndex);
	}

	inline int CListBox::AddString(LPCTSTR lpszItem) const
	// Adds a string to a list box and returns its index.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_ADDSTRING, 0, (LPARAM)lpszItem);
	}

	inline int CListBox::DeleteString(UINT nIndex) const
	// Removes a string from a list box and returns the number of strings remaining in the list.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_DELETESTRING, nIndex, 0);
	}

	inline int CListBox::Dir(UINT attr, LPCTSTR lpszWildCard) const
	// Adds a list of filenames to a list box and returns the index of the last filename added.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_DIR, attr, (LPARAM)lpszWildCard);
	}

	inline int CListBox::FindString(int nStartAfter, LPCTSTR lpszItem) const
	// Returns the index of the first string in the list box that begins with a specified string.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);
	}

	inline int CListBox::FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
	// Returns the index of the string in the list box that is equal to a specified string.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
	}

	inline int CListBox::InsertString(int nIndex, LPCTSTR lpszItem) const
	// Inserts a string at a specified index in a list box.
	{
		assert(::IsWindow(m_hWnd));
		return (int)SendMessage(LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);
	}

	inline void CListBox::ResetContent() const
	// Removes all items from a list box.
	{
		assert(::IsWindow(m_hWnd));
		SendMessage(LB_RESETCONTENT, 0, 0);
	}

	inline int CListBox::SelectString(int nStartAfter, LPCTSTR lpszItem) const
	// Selects the first string it finds that matches a specified prefix.
	{
		assert(::IsWindow(m_hWnd));
		return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);
	}

	inline void CListBox::PreRegisterClass(WNDCLASS &wc)
	{
		// Set the Window Class
		wc.lpszClassName =  _T("ListBox");
	}


	////////////////////////////////////////
	// Definitions for the CStatic class
	//
	inline HBITMAP CStatic::GetBitmap() const
	// Returns the handle to the bitmap for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HBITMAP)SendMessage(STM_GETIMAGE, IMAGE_BITMAP, 0);
	}

	inline HCURSOR CStatic::GetCursor() const
	// Returns the handle to the icon for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HCURSOR)SendMessage(STM_GETIMAGE, IMAGE_CURSOR, 0);
	}

	inline HENHMETAFILE CStatic::GetEnhMetaFile() const
	// Returns the handle to the enhanced metafile for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HENHMETAFILE)SendMessage(STM_GETIMAGE, IMAGE_ENHMETAFILE, 0);
	}

	inline HICON CStatic::GetIcon() const
	// Returns the handle to the icon for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HICON)SendMessage(STM_GETIMAGE, IMAGE_ICON, 0);
	}

	inline HBITMAP CStatic::SetBitmap(HBITMAP hBitmap) const
	// Sets the handle to the bitmap for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HBITMAP)SendMessage(STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
	}

	inline HCURSOR CStatic::SetCursor(HCURSOR hCursor) const
	// Sets the handle to the cursor for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HCURSOR)SendMessage(STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
	}

	inline HENHMETAFILE CStatic::SetEnhMetaFile(HENHMETAFILE hMetaFile) const
	// Sets the handle to the enhanced metafile for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HENHMETAFILE)SendMessage(STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);
	}

	inline HICON CStatic::SetIcon(HICON hIcon) const
	// Sets the handle to the icon for the static control
	{
		assert(::IsWindow(m_hWnd));
		return (HICON)SendMessage(STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
	}

	inline void CStatic::PreRegisterClass(WNDCLASS &wc)
	{
		// Set the Window Class
		wc.lpszClassName =  _T("Static");
	}

}

#endif	// _WIN32XX_STDCONTROLS_H_