summaryrefslogtreecommitdiffstats
path: root/mmc_updater/depends/win32cpp/listview.h
blob: 810e7627bab665f81760b0b7ea52cb5b60d9855a (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
// 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.
//
////////////////////////////////////////////////////////



#ifndef _WIN32XX_LISTVIEW_H_
#define _WIN32XX_LISTVIEW_H_

#include "wincore.h"
#include "commctrl.h"

namespace Win32xx
{

	class CListView : public CWnd
	{
	public:
		CListView() {}
		virtual ~CListView() {}
		virtual void PreRegisterClass(WNDCLASS &wc);

		// Attributes
		CSize ApproximateViewRect(CSize sz = CSize(-1, -1), int iCount = -1) const;
		COLORREF GetBkColor( ) const;
		BOOL GetBkImage( LVBKIMAGE& lvbkImage ) const;
		UINT GetCallbackMask( ) const;
		BOOL GetCheckState( UINT nItem ) const;
		BOOL GetColumn( int iCol, LVCOLUMN& Column ) const;
		BOOL GetColumnOrderArray( LPINT piArray, int iCount = -1 );
		int GetColumnWidth( int iCol ) const;
		int GetCountPerPage( ) const;
		HWND GetEditControl( ) const;
		DWORD GetExtendedStyle( ) const;
		HWND GetHeader( ) const;
		HCURSOR GetHotCursor( );
		int GetHotItem( ) const;
		DWORD GetHoverTime( ) const;
		HIMAGELIST GetImageList( int nImageType ) const;
		BOOL GetItem( LVITEM& lvItem ) const;
		int GetItemCount( ) const;
		DWORD_PTR GetItemData( int iItem ) const;
		BOOL GetItemPosition( int iItem, CPoint& pt ) const;
		BOOL GetItemRect( int iItem, CRect& rc, UINT nCode ) const;
		UINT GetItemState( int iItem, UINT nMask ) const;
		tString GetItemText( int iItem, int iSubItem, UINT nTextMax = 260 ) const;
		int GetNextItem( int iItem, int iFlags ) const;
		UINT GetNumberOfWorkAreas( ) const;
		BOOL GetOrigin( CPoint& pt ) const;
		UINT GetSelectedCount( ) const;
		int GetSelectionMark( ) const;
		int GetStringWidth( LPCTSTR pszString ) const;
		BOOL GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const;
		COLORREF GetTextBkColor( ) const;
		COLORREF GetTextColor( ) const;
		HWND GetToolTips( ) const;
		int GetTopIndex( ) const;
		BOOL GetViewRect( CRect& rc ) const;
		void GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const;
		BOOL SetBkColor( COLORREF clrBk ) const;
		BOOL SetBkImage( LVBKIMAGE& plvbkImage ) const;
		BOOL SetCallbackMask( UINT nMask ) const;
		void SetCheckState( int iItem, BOOL fCheck = TRUE ) const;
		BOOL SetColumn( int iCol, const LVCOLUMN& pColumn ) const;
		BOOL SetColumnOrderArray( int iCount, LPINT piArray ) const;
		BOOL SetColumnWidth( int iCol, int cx ) const;
		DWORD SetExtendedStyle( DWORD dwNewStyle ) const;
		HCURSOR SetHotCursor( HCURSOR hCursor ) const;
		int SetHotItem( int nIndex ) const;
		DWORD SetHoverTime( DWORD dwHoverTime = (DWORD)-1 ) const;
		CSize SetIconSpacing( int cx, int cy ) const;
		CSize SetIconSpacing( CSize sz ) const;
		HIMAGELIST SetImageList( HIMAGELIST himl, int iImageListType ) const;
		BOOL SetItem( LVITEM& pItem ) const;
		BOOL SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,
						UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const;
		void SetItemCount( int iCount ) const;
		void SetItemCountEx( int iCount, DWORD dwFlags = LVSICF_NOINVALIDATEALL ) const;
		BOOL SetItemData( int iItem, DWORD_PTR dwData ) const;
		BOOL SetItemPosition( int iItem, CPoint& pt ) const;
		BOOL SetItemState( int iItem, LVITEM& Item ) const;
        void SetItemState( int iItem, UINT nState, UINT nMask ) const;
		void SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const;
		int SetSelectionMark( int iIndex ) const;
		BOOL SetTextBkColor( COLORREF clrBkText ) const;
		BOOL SetTextColor( COLORREF clrText ) const;
		HWND SetToolTips( HWND hWndToolTip ) const;
		void SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const;
		int SubItemHitTest( LVHITTESTINFO& htInfo ) const;

		// Operations
		BOOL Arrange( UINT nCode ) const;
		HIMAGELIST CreateDragImage( int iItem, CPoint& pt ) const;
		BOOL DeleteAllItems( ) const;
		BOOL DeleteColumn( int iCol ) const;
		BOOL DeleteItem( int iItem ) const;
		HWND EditLabel( int iItem ) const;
		BOOL EnsureVisible( int iItem, BOOL fPartialOK ) const;
		int FindItem( LVFINDINFO& FindInfo, int iStart = -1 ) const;
		int HitTest( LVHITTESTINFO& HitTestInfo ) const;
        int HitTest( CPoint pt, UINT* pFlags = NULL ) const;
		int InsertColumn( int iCol, const LVCOLUMN& pColumn ) const;
        int InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat = LVCFMT_LEFT,
							int iWidth = -1, int iSubItem = -1 ) const;
		int InsertItem( const LVITEM& pItem ) const;
        int InsertItem( int iItem, LPCTSTR pszText ) const;
        int InsertItem( int iItem, LPCTSTR pszText, int iImage ) const;
		BOOL RedrawItems( int iFirst, int iLast ) const;
		BOOL Scroll( CSize sz ) const;
		BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const;
		BOOL Update( int iItem ) const;

	private:
		CListView(const CListView&);				// Disable copy construction
		CListView& operator = (const CListView&); // Disable assignment operator
	};

}

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

namespace Win32xx
{

	inline void CListView::PreRegisterClass(WNDCLASS &wc)
	{
		// Set the Window Class
		wc.lpszClassName =  WC_LISTVIEW;
	}

	inline CSize CListView::ApproximateViewRect(CSize sz /*= CSize(-1, -1)*/, int iCount /* = -1*/) const
	// Calculates the approximate width and height required to display a given number of items.
	{
		assert(::IsWindow(m_hWnd));
		return CSize( ListView_ApproximateViewRect( m_hWnd, sz.cx, sz.cy, iCount ) );
	}

	inline COLORREF CListView::GetBkColor( ) const
	// Retrieves the background color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetBkColor( m_hWnd );
	}

	inline BOOL CListView::GetBkImage( LVBKIMAGE& lvbkImage ) const
	// Retrieves the background image in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetBkImage( m_hWnd, &lvbkImage );
	}

	inline UINT CListView::GetCallbackMask( ) const
	// Retrieves the callback mask for a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetCallbackMask( m_hWnd );
	}

	inline BOOL CListView::GetCheckState( UINT nItem ) const
	// Determines if an item in a list-view control is selected.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetCheckState( m_hWnd, nItem );
	}

	inline BOOL CListView::GetColumn( int iCol, LVCOLUMN& Column ) const
	// Retrieves the attributes of a list-view control's column.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetColumn( m_hWnd, iCol, &Column );
	}

	inline BOOL CListView::GetColumnOrderArray( LPINT piArray, int iCount /*= -1*/ )
	// Retrieves the current left-to-right order of columns in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetColumnOrderArray( m_hWnd, iCount, piArray );
	}

	inline int CListView::GetColumnWidth( int iCol ) const
	// Retrieves the width of a column in report or list view.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetColumnWidth( m_hWnd, iCol );
	}

	inline int CListView::GetCountPerPage( ) const
	// Calculates the number of items that can fit vertically in the visible area of a
	// list-view control when in list or report view. Only fully visible items are counted.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetCountPerPage( m_hWnd );
	}

	inline HWND CListView::GetEditControl( ) const
	// Retrieves the handle to the edit control being used to edit a list-view item's text.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetEditControl( m_hWnd );
	}

	inline DWORD CListView::GetExtendedStyle( ) const
	// Retrieves the extended styles that are currently in use for a given list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetExtendedListViewStyle( m_hWnd );
	}

	inline HWND CListView::GetHeader( ) const
	// Retrieves the handle to the header control used by a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetHeader( m_hWnd );
	}

	inline HCURSOR CListView::GetHotCursor( )
	// Retrieves the HCURSOR used when the pointer is over an item while hot tracking is enabled.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetHotCursor( m_hWnd );
	}

	inline int CListView::GetHotItem( ) const
	// Retrieves the index of the hot item.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetHotItem( m_hWnd );
	}

	inline DWORD CListView::GetHoverTime( ) const
	// Retrieves the amount of time that the mouse cursor must hover over an item before it is selected.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetHoverTime( m_hWnd );
	}

	inline HIMAGELIST CListView::GetImageList( int nImageType ) const
	// Retrieves the handle to an image list used for drawing list-view items.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetImageList( m_hWnd, nImageType );
	}

	inline BOOL CListView::GetItem( LVITEM& Item ) const
	// Retrieves some or all of a list-view item's attributes.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetItem( m_hWnd, &Item );
	}

	inline int CListView::GetItemCount( ) const
	// Retrieves the number of items in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetItemCount( m_hWnd );
	}

	inline DWORD_PTR CListView::GetItemData( int iItem ) const
	// Retrieves the value(lParam) specific to the item.
	{
		assert(::IsWindow(m_hWnd));

		LVITEM lvi = {0};
		lvi.iItem = iItem;
		lvi.mask = LVIF_PARAM;
		ListView_GetItem(m_hWnd, &lvi);
		return lvi.lParam;
	}

	inline BOOL CListView::GetItemPosition( int iItem, CPoint& pt ) const
	// Retrieves the position of a list-view item.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetItemPosition( m_hWnd, iItem, &pt );
	}

	inline BOOL CListView::GetItemRect( int iItem, CRect& rc, UINT nCode ) const
	// Retrieves the bounding rectangle for all or part of an item in the current view.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetItemRect( m_hWnd, iItem, &rc, nCode );
	}

	inline UINT CListView::GetItemState( int iItem, UINT nMask ) const
	// Retrieves the state of a list-view item.

	// Possible values of nMask:
	// LVIS_CUT				The item is marked for a cut-and-paste operation.
	// LVIS_DROPHILITED		The item is highlighted as a drag-and-drop target.
	// LVIS_FOCUSED			The item has the focus, so it is surrounded by a standard focus rectangle.
	// LVIS_SELECTED		The item is selected.
	// LVIS_OVERLAYMASK		Use this mask to retrieve the item's overlay image index.
	// LVIS_STATEIMAGEMASK	Use this mask to retrieve the item's state image index.
	{
		assert(::IsWindow(m_hWnd));
		return  ListView_GetItemState( m_hWnd, iItem, nMask );
	}

	inline tString CListView::GetItemText( int iItem, int iSubItem, UINT nTextMax /* = 260 */ ) const
	// Retrieves the text of a list-view item.
	// Note: Although the list-view control allows any length string to be stored
	//       as item text, only the first 260 characters are displayed.
	{
		assert(::IsWindow(m_hWnd));

		tString t;
		if (nTextMax > 0)
		{
			std::vector<TCHAR> vTChar(nTextMax +1, _T('\0'));
			TCHAR* pszText = &vTChar.front();
			LVITEM lvi = {0};
			lvi.iItem = iItem;
			lvi.iSubItem = iSubItem;
			lvi.mask = LVIF_TEXT;
			lvi.cchTextMax = nTextMax;
			lvi.pszText = pszText;
			ListView_GetItem( m_hWnd, &lvi );
			t = lvi.pszText;
		}
		return t;
	}

	inline int CListView::GetNextItem( int iItem, int iFlags ) const
	// Searches for a list-view item that has the specified properties and
	// bears the specified relationship to a specified item.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetNextItem( m_hWnd, iItem, iFlags );
	}

	inline UINT CListView::GetNumberOfWorkAreas( ) const
	// Retrieves the working areas from a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		UINT nWorkAreas = 0;
		ListView_GetWorkAreas( m_hWnd, nWorkAreas, NULL );
		return nWorkAreas;
	}

	inline BOOL CListView::GetOrigin( CPoint& pt ) const
	// Retrieves the current view origin for a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetOrigin( m_hWnd, &pt );
	}

	inline UINT CListView::GetSelectedCount( ) const
	// Determines the number of selected items in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return (UINT)::SendMessage( m_hWnd, LVM_GETSELECTEDCOUNT, 0L, 0L );
	}

	inline int CListView::GetSelectionMark( ) const
	// Retrieves the selection mark from a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return (int)::SendMessage( m_hWnd, LVM_GETSELECTIONMARK, 0L, 0L );
	}

	inline int CListView::GetStringWidth( LPCTSTR pszString ) const
	// Determines the width of a specified string using the specified list-view control's current font.
	{
		assert(::IsWindow(m_hWnd));
		return (int)::SendMessage( m_hWnd, LVM_GETSTRINGWIDTH, 0L, (LPARAM)pszString );
	}

	inline BOOL CListView::GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const
	// Retrieves information about the rectangle that surrounds a subitem in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetSubItemRect( m_hWnd, iItem, iSubItem, iCode, &rc );
	}

	inline COLORREF CListView::GetTextBkColor( ) const
	// Retrieves the text background color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetTextBkColor( m_hWnd );
	}

	inline COLORREF CListView::GetTextColor( ) const
	// Retrieves the text color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetTextColor( m_hWnd );
	}

	inline HWND CListView::GetToolTips( ) const
	// Retrieves the ToolTip control that the list-view control uses to display ToolTips.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetToolTips( m_hWnd );
	}

	inline int CListView::GetTopIndex( ) const
	// Retrieves the index of the topmost visible item when in list or report view.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetTopIndex( m_hWnd );
	}

	inline BOOL CListView::GetViewRect( CRect& rc ) const
	// Retrieves the bounding rectangle of all items in the list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_GetViewRect( m_hWnd, &rc );
	}

	inline void CListView::GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const
	// Retrieves the working areas from a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		ListView_GetWorkAreas( m_hWnd, iWorkAreas, pRectArray );
	}

	inline BOOL CListView::SetBkColor( COLORREF clrBk ) const
	// Sets the background color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetBkColor( m_hWnd, clrBk );
	}

	inline BOOL CListView::SetBkImage( LVBKIMAGE& lvbkImage ) const
	// Sets the background image in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetBkImage( m_hWnd, &lvbkImage );
	}

	inline BOOL CListView::SetCallbackMask( UINT nMask ) const
	// Changes the callback mask for a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetCallbackMask( m_hWnd, nMask );
	}

	inline void CListView::SetCheckState( int iItem, BOOL fCheck /*= TRUE*/ ) const
	// Used to select or deselect an item in a list-view control.
	// This macro should only be used for list-view controls with the LVS_EX_CHECKBOXES style.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetItemState(m_hWnd, iItem, INDEXTOSTATEIMAGEMASK((fCheck==TRUE)?2:1),LVIS_STATEIMAGEMASK);
	}

	inline BOOL CListView::SetColumn( int iCol, const LVCOLUMN& Column ) const
	// Sets the attributes of a list-view column.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetColumn( m_hWnd, iCol, &Column );
	}

	inline BOOL CListView::SetColumnOrderArray( int iCount, LPINT piArray ) const
	// Sets the left-to-right order of columns in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetColumnOrderArray( m_hWnd, iCount, piArray );
	}

	inline BOOL CListView::SetColumnWidth( int iCol, int cx ) const
	// Used to change the width of a column in report view or the width of all columns in list-view mode.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetColumnWidth( m_hWnd, iCol, cx );
	}

	inline DWORD CListView::SetExtendedStyle( DWORD dwNewStyle ) const
	// Sets extended styles for list-view controls.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetExtendedListViewStyle( m_hWnd, dwNewStyle );
	}

	inline HCURSOR CListView::SetHotCursor( HCURSOR hCursor ) const
	// Sets the HCURSOR that the list-view control uses when the pointer is
	// over an item while hot tracking is enabled.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetHotCursor( m_hWnd, hCursor );
	}

	inline int CListView::SetHotItem( int nIndex ) const
	// Sets the hot item in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetHotItem( m_hWnd, nIndex );
	}

	inline DWORD CListView::SetHoverTime( DWORD dwHoverTime /*= (DWORD)-1*/ ) const
	// Sets the amount of time that the mouse cursor must hover over an item before it is selected.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetHoverTime( m_hWnd, dwHoverTime );
	}

	inline CSize CListView::SetIconSpacing( int cx, int cy ) const
	// Sets the spacing between icons in list-view controls set to the LVS_ICON style.
	{
		assert(::IsWindow(m_hWnd));
		return CSize( ListView_SetIconSpacing( m_hWnd, cx, cy ) );
	}

	inline CSize CListView::SetIconSpacing( CSize sz ) const
	// Sets the spacing between icons in list-view controls set to the LVS_ICON style.
	{
		assert(::IsWindow(m_hWnd));
		return CSize( ListView_SetIconSpacing( m_hWnd, sz.cx, sz.cy ) );
	}

	inline HIMAGELIST CListView::SetImageList( HIMAGELIST himl, int iImageListType ) const
	// Assigns an image list to a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetImageList( m_hWnd, himl, iImageListType );
	}

	inline BOOL CListView::SetItem( LVITEM& Item ) const
	// Sets some or all of a list-view item's attributes.

	// The declaration for TVITEM:
	//	typedef struct _LVITEM {
	//		UINT mask;
	//		int iItem;
	//		int iSubItem;
	//		UINT state;
	//		UINT stateMask;
	//		LPTSTR pszText;
	//		int cchTextMax;
    //		int iImage;
	//		LPARAM lParam;
	// } LVITEM, *LVITEM&;
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetItem( m_hWnd, &Item );
	}

	inline BOOL CListView::SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,
					UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const
	// Sets some or all of a list-view item's attributes.
	{
		assert(::IsWindow(m_hWnd));

		LVITEM lvi = {0};
		lvi.iItem = iItem;
		lvi.iSubItem = iSubItem;
		lvi.mask = nMask;
		lvi.pszText = (LPTSTR)pszText;
		lvi.iImage = iImage;
		lvi.state = nState;
		lvi.stateMask = nStateMask;
		lvi.lParam = lParam;
		lvi.iIndent = iIndent;

		return ListView_SetItem( m_hWnd, &lvi);
	}

	inline void CListView::SetItemCount( int iCount ) const
	// Causes the list-view control to allocate memory for the specified number of items.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetItemCount( m_hWnd, iCount );
	}

	inline void CListView::SetItemCountEx( int iCount, DWORD dwFlags /*= LVSICF_NOINVALIDATEALL*/ ) const
	// Sets the virtual number of items in a virtual list view.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetItemCountEx( m_hWnd, iCount, dwFlags );
	}

	inline BOOL CListView::SetItemData( int iItem, DWORD_PTR dwData ) const
	// Sets the value(lParam) specific to the item.
	{
		assert(::IsWindow(m_hWnd));

		LVITEM lvi = {0};
		lvi.iItem = iItem;
		lvi.lParam = dwData;
		lvi.mask = LVIF_PARAM;
		return ListView_SetItem(m_hWnd, &lvi);
	}

	inline BOOL CListView::SetItemPosition( int iItem, CPoint& pt ) const
	// Moves an item to a specified position in a list-view control (in icon or small icon view).
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetItemPosition( m_hWnd, iItem, pt.x, pt.y );
	}

	inline BOOL CListView::SetItemState( int iItem, LVITEM& Item ) const
	// Changes the state of an item in a list-view control.

	// Possible values of nMask:
	// LVIS_CUT				The item is marked for a cut-and-paste operation.
	// LVIS_DROPHILITED		The item is highlighted as a drag-and-drop target.
	// LVIS_FOCUSED			The item has the focus, so it is surrounded by a standard focus rectangle.
	// LVIS_SELECTED		The item is selected.
	// LVIS_OVERLAYMASK		Use this mask to retrieve the item's overlay image index.
	// LVIS_STATEIMAGEMASK	Use this mask to retrieve the item's state image index.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, (WPARAM)iItem, (LPARAM)&Item);
	}

    inline void CListView::SetItemState( int iItem, UINT nState, UINT nMask ) const
	// Changes the state of an item in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetItemState(m_hWnd, iItem, nState, nMask);
	}

	inline void CListView::SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const
	// Sets the text color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetItemText(m_hWnd, iItem, iSubItem, (LPTSTR)pszText );
	}

	inline int CListView::SetSelectionMark( int iIndex ) const
	// Sets the selection mark in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetSelectionMark( m_hWnd, iIndex );
	}

	inline BOOL CListView::SetTextBkColor( COLORREF clrBkText ) const
	// Sets the background color of text in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetTextBkColor( m_hWnd, clrBkText );
	}

	inline BOOL CListView::SetTextColor( COLORREF clrText ) const
	// Sets the text color of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SetTextColor( m_hWnd, clrText );
	}

	inline HWND CListView::SetToolTips( HWND hWndToolTip ) const
	// Sets the ToolTip control that the list-view control will use to display ToolTips.
	{
		assert(::IsWindow(m_hWnd));
		return (HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndToolTip, 0L);
	}

	inline void CListView::SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const
	// Sets the working area within a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		ListView_SetWorkAreas( m_hWnd, nWorkAreas, pRectArray );
	}

	inline int CListView::SubItemHitTest( LVHITTESTINFO& htInfo ) const
	// Determines which list-view item or subitem is located at a given position.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SubItemHitTest( m_hWnd, &htInfo );
	}

	// Operations

	inline BOOL CListView::Arrange( UINT nCode ) const
	// Arranges items in icon view.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_Arrange( m_hWnd, nCode );
	}

	inline HIMAGELIST CListView::CreateDragImage( int iItem, CPoint& pt ) const
	// Creates a drag image list for the specified item.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_CreateDragImage( m_hWnd, iItem, &pt );
	}

	inline BOOL CListView::DeleteAllItems( ) const
	// ListView_DeleteAllItems
	{
		assert(::IsWindow(m_hWnd));
		return ListView_DeleteAllItems( m_hWnd );
	}

	inline BOOL CListView::DeleteColumn( int iCol ) const
	// Removes a column from a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_DeleteColumn( m_hWnd, iCol );
	}

	inline BOOL CListView::DeleteItem( int iItem ) const
	// Removes an item from a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_DeleteItem( m_hWnd, iItem );
	}

	inline HWND CListView::EditLabel( int iItem ) const
	// Begins in-place editing of the specified list-view item's text.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_EditLabel( m_hWnd, iItem );
	}

	inline BOOL CListView::EnsureVisible( int iItem, BOOL fPartialOK ) const
	// Ensures that a list-view item is either entirely or partially visible,
	// scrolling the list-view control if necessary.
	{
		assert(::IsWindow(m_hWnd));
		return (BOOL)SendMessage(LVM_ENSUREVISIBLE, (WPARAM)iItem, (LPARAM)fPartialOK );
	}

	inline int CListView::FindItem( LVFINDINFO& FindInfo, int iStart /*= -1*/ ) const
	// Searches for a list-view item with the specified characteristics.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_FindItem( m_hWnd, iStart, &FindInfo );
	}

	inline int CListView::HitTest( LVHITTESTINFO& HitTestInfo ) const
	// Determines which list-view item, if any, is at a specified position.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_HitTest( m_hWnd, &HitTestInfo );
	}

    inline int CListView::HitTest( CPoint pt, UINT* pFlags /*= NULL*/ ) const
	// Determines which list-view item, if any, is at a specified position.
	{
		assert(::IsWindow(m_hWnd));

		LVHITTESTINFO hti = {0};
		hti.flags = *pFlags;
		hti.pt = pt;
		return ListView_HitTest( m_hWnd, &hti );
	}

	inline int CListView::InsertColumn( int iCol, const LVCOLUMN& Column ) const
	// Inserts a new column in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_InsertColumn( m_hWnd, iCol, &Column );
	}

    inline int CListView::InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat /*= LVCFMT_LEFT*/,
						int iWidth /*= -1*/, int iSubItem /*= -1*/ ) const
	// Inserts a new column in a list-view control.
	{
		assert(::IsWindow(m_hWnd));

		LVCOLUMN lvc = {0};
		lvc.mask = LVCF_TEXT|LVCF_ORDER|LVCF_FMT;
		if (-1 != iWidth)
		{
			lvc.mask |= LVCF_WIDTH; 
			lvc.cx = iWidth; 
		}
		if (-1 !=  iSubItem)
		{
			lvc.mask |= LVCF_SUBITEM; 
			lvc.iSubItem = iSubItem;
		}

		lvc.iOrder = iCol;
		lvc.pszText = (LPTSTR)pszColumnHeading;
		lvc.fmt = iFormat;
		lvc.iSubItem = iSubItem;
		return ListView_InsertColumn( m_hWnd, iCol, &lvc );
	}

	inline int CListView::InsertItem( const LVITEM& Item ) const
	// Inserts a new item in a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_InsertItem( m_hWnd, &Item );
	}

    inline int CListView::InsertItem( int iItem, LPCTSTR pszText ) const
	// Inserts a new item in a list-view control.
	{
		assert(::IsWindow(m_hWnd));

		LVITEM lvi = {0};
		lvi.iItem = iItem;
		lvi.pszText = (LPTSTR)pszText;
		lvi.mask = LVIF_TEXT;
		return ListView_InsertItem( m_hWnd, &lvi );
	}

    inline int CListView::InsertItem( int iItem, LPCTSTR pszText, int iImage ) const
	// Inserts a new item in a list-view control.
	{
		assert(::IsWindow(m_hWnd));

		LVITEM lvi = {0};
		lvi.iItem = iItem;
		lvi.pszText = (LPTSTR)pszText;
		lvi.iImage = iImage;
		lvi.mask = LVIF_TEXT | LVIF_IMAGE;
		return ListView_InsertItem( m_hWnd, &lvi );
	}

	inline BOOL CListView::RedrawItems( int iFirst, int iLast ) const
	// Forces a list-view control to redraw a range of items.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_RedrawItems( m_hWnd, iFirst, iLast );
	}

	inline BOOL CListView::Scroll( CSize sz ) const
	// Scrolls the content of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_Scroll( m_hWnd, sz.cx, sz.cy );
	}

	inline BOOL CListView::SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const
	// Uses an application-defined comparison function to sort the items of a list-view control.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_SortItems( m_hWnd, pfnCompare, dwData );
	}

	inline BOOL CListView::Update( int iItem ) const
	// Updates a list-view item. If the list-view control has the LVS_AUTOARRANGE style,
	// the list-view control is rearranged.
	{
		assert(::IsWindow(m_hWnd));
		return ListView_Update( m_hWnd, iItem );
	}

} // namespace Win32xx

#endif // #ifndef _WIN32XX_LISTVIEW_H_