e68311115f625810486146057597e761c617f5e0
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / include / listview.h
1 // Win32++   Version 7.3\r
2 // Released: 30th November 2011\r
3 //\r
4 //      David Nash\r
5 //      email: [email protected]\r
6 //      url: https://sourceforge.net/projects/win32-framework\r
7 //\r
8 //\r
9 // Copyright (c) 2005-2011  David Nash\r
10 //\r
11 // Permission is hereby granted, free of charge, to\r
12 // any person obtaining a copy of this software and\r
13 // associated documentation files (the "Software"),\r
14 // to deal in the Software without restriction, including\r
15 // without limitation the rights to use, copy, modify,\r
16 // merge, publish, distribute, sublicense, and/or sell\r
17 // copies of the Software, and to permit persons to whom\r
18 // the Software is furnished to do so, subject to the\r
19 // following conditions:\r
20 //\r
21 // The above copyright notice and this permission notice\r
22 // shall be included in all copies or substantial portions\r
23 // of the Software.\r
24 //\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.\r
34 //\r
35 ////////////////////////////////////////////////////////\r
36 \r
37 \r
38 \r
39 #ifndef _WIN32XX_LISTVIEW_H_\r
40 #define _WIN32XX_LISTVIEW_H_\r
41 \r
42 #include "wincore.h"\r
43 #include "commctrl.h"\r
44 \r
45 namespace Win32xx\r
46 {\r
47 \r
48         class CListView : public CWnd\r
49         {\r
50         public:\r
51                 CListView() {}\r
52                 virtual ~CListView() {}\r
53                 virtual void PreRegisterClass(WNDCLASS &wc);\r
54 \r
55                 // Attributes\r
56                 CSize ApproximateViewRect(CSize sz = CSize(-1, -1), int iCount = -1) const;\r
57                 COLORREF GetBkColor( ) const;\r
58                 BOOL GetBkImage( LVBKIMAGE& lvbkImage ) const;\r
59                 UINT GetCallbackMask( ) const;\r
60                 BOOL GetCheckState( UINT nItem ) const;\r
61                 BOOL GetColumn( int iCol, LVCOLUMN& Column ) const;\r
62                 BOOL GetColumnOrderArray( LPINT piArray, int iCount = -1 );\r
63                 int GetColumnWidth( int iCol ) const;\r
64                 int GetCountPerPage( ) const;\r
65                 CEdit* GetEditControl( ) const;\r
66                 DWORD GetExtendedStyle( ) const;\r
67                 CHeader* GetHeader( ) const;\r
68                 HCURSOR GetHotCursor( );\r
69                 int GetHotItem( ) const;\r
70                 DWORD GetHoverTime( ) const;\r
71                 HIMAGELIST GetImageList( int nImageType ) const;\r
72                 BOOL GetItem( LVITEM& lvItem ) const;\r
73                 int GetItemCount( ) const;\r
74                 DWORD_PTR GetItemData( int iItem ) const;\r
75                 BOOL GetItemPosition( int iItem, CPoint& pt ) const;\r
76                 BOOL GetItemRect( int iItem, CRect& rc, UINT nCode ) const;\r
77                 UINT GetItemState( int iItem, UINT nMask ) const;\r
78                 CString GetItemText( int iItem, int iSubItem, UINT nTextMax = 260 ) const;\r
79                 int GetNextItem( int iItem, int iFlags ) const;\r
80                 UINT GetNumberOfWorkAreas( ) const;\r
81                 BOOL GetOrigin( CPoint& pt ) const;\r
82                 UINT GetSelectedCount( ) const;\r
83                 int GetSelectionMark( ) const;\r
84                 int GetStringWidth( LPCTSTR pszString ) const;\r
85                 BOOL GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const;\r
86                 COLORREF GetTextBkColor( ) const;\r
87                 COLORREF GetTextColor( ) const;\r
88                 CToolTip* GetToolTips( ) const;\r
89                 int GetTopIndex( ) const;\r
90                 BOOL GetViewRect( CRect& rc ) const;\r
91                 void GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const;\r
92                 BOOL SetBkColor( COLORREF clrBk ) const;\r
93                 BOOL SetBkImage( LVBKIMAGE& plvbkImage ) const;\r
94                 BOOL SetCallbackMask( UINT nMask ) const;\r
95                 void SetCheckState( int iItem, BOOL fCheck = TRUE ) const;\r
96                 BOOL SetColumn( int iCol, const LVCOLUMN& pColumn ) const;\r
97                 BOOL SetColumnOrderArray( int iCount, LPINT piArray ) const;\r
98                 BOOL SetColumnWidth( int iCol, int cx ) const;\r
99                 DWORD SetExtendedStyle( DWORD dwNewStyle ) const;\r
100                 HCURSOR SetHotCursor( HCURSOR hCursor ) const;\r
101                 int SetHotItem( int nIndex ) const;\r
102                 DWORD SetHoverTime( DWORD dwHoverTime = (DWORD)-1 ) const;\r
103                 CSize SetIconSpacing( int cx, int cy ) const;\r
104                 CSize SetIconSpacing( CSize sz ) const;\r
105                 HIMAGELIST SetImageList( HIMAGELIST himl, int iImageListType ) const;\r
106                 BOOL SetItem( LVITEM& pItem ) const;\r
107                 BOOL SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,\r
108                                                 UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const;\r
109                 void SetItemCount( int iCount ) const;\r
110                 void SetItemCountEx( int iCount, DWORD dwFlags = LVSICF_NOINVALIDATEALL ) const;\r
111                 BOOL SetItemData( int iItem, DWORD_PTR dwData ) const;\r
112                 BOOL SetItemPosition( int iItem, CPoint& pt ) const;\r
113                 BOOL SetItemState( int iItem, LVITEM& Item ) const;\r
114         void SetItemState( int iItem, UINT nState, UINT nMask ) const;\r
115                 void SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const;\r
116                 int SetSelectionMark( int iIndex ) const;\r
117                 BOOL SetTextBkColor( COLORREF clrBkText ) const;\r
118                 BOOL SetTextColor( COLORREF clrText ) const;\r
119                 CToolTip* SetToolTips ( CToolTip* pToolTip ) const;\r
120                 void SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const;\r
121                 int SubItemHitTest( LVHITTESTINFO& htInfo ) const;\r
122 \r
123                 // Operations\r
124                 BOOL Arrange( UINT nCode ) const;\r
125                 HIMAGELIST CreateDragImage( int iItem, CPoint& pt ) const;\r
126                 BOOL DeleteAllItems( ) const;\r
127                 BOOL DeleteColumn( int iCol ) const;\r
128                 BOOL DeleteItem( int iItem ) const;\r
129                 CEdit* EditLabel( int iItem ) const;\r
130                 BOOL EnsureVisible( int iItem, BOOL fPartialOK ) const;\r
131                 int FindItem( LVFINDINFO& FindInfo, int iStart = -1 ) const;\r
132                 int HitTest( LVHITTESTINFO& HitTestInfo ) const;\r
133         int HitTest( CPoint pt, UINT* pFlags = NULL ) const;\r
134                 int InsertColumn( int iCol, const LVCOLUMN& pColumn ) const;\r
135         int InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat = LVCFMT_LEFT,\r
136                                                         int iWidth = -1, int iSubItem = -1 ) const;\r
137                 int InsertItem( const LVITEM& pItem ) const;\r
138         int InsertItem( int iItem, LPCTSTR pszText ) const;\r
139         int InsertItem( int iItem, LPCTSTR pszText, int iImage ) const;\r
140                 BOOL RedrawItems( int iFirst, int iLast ) const;\r
141                 BOOL Scroll( CSize sz ) const;\r
142                 BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const;\r
143                 BOOL Update( int iItem ) const;\r
144 \r
145         private:\r
146                 CListView(const CListView&);                            // Disable copy construction\r
147                 CListView& operator = (const CListView&); // Disable assignment operator\r
148         };\r
149 \r
150 }\r
151 \r
152 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
153 \r
154 namespace Win32xx\r
155 {\r
156 \r
157         inline void CListView::PreRegisterClass(WNDCLASS &wc)\r
158         {\r
159                 // Set the Window Class\r
160                 wc.lpszClassName =  WC_LISTVIEW;\r
161         }\r
162 \r
163         inline CSize CListView::ApproximateViewRect(CSize sz /*= CSize(-1, -1)*/, int iCount /* = -1*/) const\r
164         // Calculates the approximate width and height required to display a given number of items.\r
165         {\r
166                 assert(::IsWindow(m_hWnd));\r
167                 return CSize( ListView_ApproximateViewRect( m_hWnd, sz.cx, sz.cy, iCount ) );\r
168         }\r
169 \r
170         inline COLORREF CListView::GetBkColor( ) const\r
171         // Retrieves the background color of a list-view control.\r
172         {\r
173                 assert(::IsWindow(m_hWnd));\r
174                 return ListView_GetBkColor( m_hWnd );\r
175         }\r
176 \r
177         inline BOOL CListView::GetBkImage( LVBKIMAGE& lvbkImage ) const\r
178         // Retrieves the background image in a list-view control.\r
179         {\r
180                 assert(::IsWindow(m_hWnd));\r
181                 return ListView_GetBkImage( m_hWnd, &lvbkImage );\r
182         }\r
183 \r
184         inline UINT CListView::GetCallbackMask( ) const\r
185         // Retrieves the callback mask for a list-view control.\r
186         {\r
187                 assert(::IsWindow(m_hWnd));\r
188                 return ListView_GetCallbackMask( m_hWnd );\r
189         }\r
190 \r
191         inline BOOL CListView::GetCheckState( UINT nItem ) const\r
192         // Determines if an item in a list-view control is selected.\r
193         {\r
194                 assert(::IsWindow(m_hWnd));\r
195                 return ListView_GetCheckState( m_hWnd, nItem );\r
196         }\r
197 \r
198         inline BOOL CListView::GetColumn( int iCol, LVCOLUMN& Column ) const\r
199         // Retrieves the attributes of a list-view control's column.\r
200         {\r
201                 assert(::IsWindow(m_hWnd));\r
202                 return ListView_GetColumn( m_hWnd, iCol, &Column );\r
203         }\r
204 \r
205         inline BOOL CListView::GetColumnOrderArray( LPINT piArray, int iCount /*= -1*/ )\r
206         // Retrieves the current left-to-right order of columns in a list-view control.\r
207         {\r
208                 assert(::IsWindow(m_hWnd));\r
209                 return ListView_GetColumnOrderArray( m_hWnd, iCount, piArray );\r
210         }\r
211 \r
212         inline int CListView::GetColumnWidth( int iCol ) const\r
213         // Retrieves the width of a column in report or list view.\r
214         {\r
215                 assert(::IsWindow(m_hWnd));\r
216                 return ListView_GetColumnWidth( m_hWnd, iCol );\r
217         }\r
218 \r
219         inline int CListView::GetCountPerPage( ) const\r
220         // Calculates the number of items that can fit vertically in the visible area of a\r
221         // list-view control when in list or report view. Only fully visible items are counted.\r
222         {\r
223                 assert(::IsWindow(m_hWnd));\r
224                 return ListView_GetCountPerPage( m_hWnd );\r
225         }\r
226 \r
227         inline CEdit* CListView::GetEditControl( ) const\r
228         // Retrieves the handle to the edit control being used to edit a list-view item's text.\r
229         {\r
230                 assert(::IsWindow(m_hWnd));\r
231                 return (CEdit*)FromHandle(ListView_GetEditControl( m_hWnd ));\r
232         }\r
233 \r
234         inline DWORD CListView::GetExtendedStyle( ) const\r
235         // Retrieves the extended styles that are currently in use for a given list-view control.\r
236         {\r
237                 assert(::IsWindow(m_hWnd));\r
238                 return ListView_GetExtendedListViewStyle( m_hWnd );\r
239         }\r
240 \r
241         inline CHeader* CListView::GetHeader( ) const\r
242         // Retrieves the handle to the header control used by a list-view control.\r
243         {\r
244                 assert(::IsWindow(m_hWnd));\r
245                 return (CHeader*)FromHandle(ListView_GetHeader( m_hWnd ));\r
246         }\r
247 \r
248         inline HCURSOR CListView::GetHotCursor( )\r
249         // Retrieves the HCURSOR used when the pointer is over an item while hot tracking is enabled.\r
250         {\r
251                 assert(::IsWindow(m_hWnd));\r
252                 return ListView_GetHotCursor( m_hWnd );\r
253         }\r
254 \r
255         inline int CListView::GetHotItem( ) const\r
256         // Retrieves the index of the hot item.\r
257         {\r
258                 assert(::IsWindow(m_hWnd));\r
259                 return ListView_GetHotItem( m_hWnd );\r
260         }\r
261 \r
262         inline DWORD CListView::GetHoverTime( ) const\r
263         // Retrieves the amount of time that the mouse cursor must hover over an item before it is selected.\r
264         {\r
265                 assert(::IsWindow(m_hWnd));\r
266                 return ListView_GetHoverTime( m_hWnd );\r
267         }\r
268 \r
269         inline HIMAGELIST CListView::GetImageList( int nImageType ) const\r
270         // Retrieves the handle to an image list used for drawing list-view items.\r
271         {\r
272                 assert(::IsWindow(m_hWnd));\r
273                 return ListView_GetImageList( m_hWnd, nImageType );\r
274         }\r
275 \r
276         inline BOOL CListView::GetItem( LVITEM& Item ) const\r
277         // Retrieves some or all of a list-view item's attributes.\r
278         {\r
279                 assert(::IsWindow(m_hWnd));\r
280                 return ListView_GetItem( m_hWnd, &Item );\r
281         }\r
282 \r
283         inline int CListView::GetItemCount( ) const\r
284         // Retrieves the number of items in a list-view control.\r
285         {\r
286                 assert(::IsWindow(m_hWnd));\r
287                 return ListView_GetItemCount( m_hWnd );\r
288         }\r
289 \r
290         inline DWORD_PTR CListView::GetItemData( int iItem ) const\r
291         // Retrieves the value(lParam) specific to the item.\r
292         {\r
293                 assert(::IsWindow(m_hWnd));\r
294 \r
295                 LVITEM lvi = {0};\r
296                 lvi.iItem = iItem;\r
297                 lvi.mask = LVIF_PARAM;\r
298                 ListView_GetItem(m_hWnd, &lvi);\r
299                 return lvi.lParam;\r
300         }\r
301 \r
302         inline BOOL CListView::GetItemPosition( int iItem, CPoint& pt ) const\r
303         // Retrieves the position of a list-view item.\r
304         {\r
305                 assert(::IsWindow(m_hWnd));\r
306                 return ListView_GetItemPosition( m_hWnd, iItem, &pt );\r
307         }\r
308 \r
309         inline BOOL CListView::GetItemRect( int iItem, CRect& rc, UINT nCode ) const\r
310         // Retrieves the bounding rectangle for all or part of an item in the current view.\r
311         {\r
312                 assert(::IsWindow(m_hWnd));\r
313                 return ListView_GetItemRect( m_hWnd, iItem, &rc, nCode );\r
314         }\r
315 \r
316         inline UINT CListView::GetItemState( int iItem, UINT nMask ) const\r
317         // Retrieves the state of a list-view item.\r
318 \r
319         // Possible values of nMask:\r
320         // LVIS_CUT                             The item is marked for a cut-and-paste operation.\r
321         // LVIS_DROPHILITED             The item is highlighted as a drag-and-drop target.\r
322         // LVIS_FOCUSED                 The item has the focus, so it is surrounded by a standard focus rectangle.\r
323         // LVIS_SELECTED                The item is selected.\r
324         // LVIS_OVERLAYMASK             Use this mask to retrieve the item's overlay image index.\r
325         // LVIS_STATEIMAGEMASK  Use this mask to retrieve the item's state image index.\r
326         {\r
327                 assert(::IsWindow(m_hWnd));\r
328                 return  ListView_GetItemState( m_hWnd, iItem, nMask );\r
329         }\r
330 \r
331         inline CString CListView::GetItemText( int iItem, int iSubItem, UINT nTextMax /* = 260 */ ) const\r
332         // Retrieves the text of a list-view item.\r
333         // Note: Although the list-view control allows any length string to be stored\r
334         //       as item text, only the first 260 characters are displayed.\r
335         {\r
336                 assert(::IsWindow(m_hWnd));\r
337 \r
338                 CString t;\r
339                 if (nTextMax > 0)\r
340                 {\r
341                         std::vector<TCHAR> vTChar(nTextMax +1, _T('\0'));\r
342                         TCHAR* pszText = &vTChar.front();\r
343                         LVITEM lvi = {0};\r
344                         lvi.iItem = iItem;\r
345                         lvi.iSubItem = iSubItem;\r
346                         lvi.mask = LVIF_TEXT;\r
347                         lvi.cchTextMax = nTextMax;\r
348                         lvi.pszText = pszText;\r
349                         ListView_GetItem( m_hWnd, &lvi );\r
350                         t = lvi.pszText;\r
351                 }\r
352                 return t;\r
353         }\r
354 \r
355         inline int CListView::GetNextItem( int iItem, int iFlags ) const\r
356         // Searches for a list-view item that has the specified properties and\r
357         // bears the specified relationship to a specified item.\r
358         {\r
359                 assert(::IsWindow(m_hWnd));\r
360                 return ListView_GetNextItem( m_hWnd, iItem, iFlags );\r
361         }\r
362 \r
363         inline UINT CListView::GetNumberOfWorkAreas( ) const\r
364         // Retrieves the working areas from a list-view control.\r
365         {\r
366                 assert(::IsWindow(m_hWnd));\r
367                 UINT nWorkAreas = 0;\r
368                 ListView_GetWorkAreas( m_hWnd, nWorkAreas, NULL );\r
369                 return nWorkAreas;\r
370         }\r
371 \r
372         inline BOOL CListView::GetOrigin( CPoint& pt ) const\r
373         // Retrieves the current view origin for a list-view control.\r
374         {\r
375                 assert(::IsWindow(m_hWnd));\r
376                 return ListView_GetOrigin( m_hWnd, &pt );\r
377         }\r
378 \r
379         inline UINT CListView::GetSelectedCount( ) const\r
380         // Determines the number of selected items in a list-view control.\r
381         {\r
382                 assert(::IsWindow(m_hWnd));\r
383                 return (UINT)::SendMessage( m_hWnd, LVM_GETSELECTEDCOUNT, 0L, 0L );\r
384         }\r
385 \r
386         inline int CListView::GetSelectionMark( ) const\r
387         // Retrieves the selection mark from a list-view control.\r
388         {\r
389                 assert(::IsWindow(m_hWnd));\r
390                 return (int)::SendMessage( m_hWnd, LVM_GETSELECTIONMARK, 0L, 0L );\r
391         }\r
392 \r
393         inline int CListView::GetStringWidth( LPCTSTR pszString ) const\r
394         // Determines the width of a specified string using the specified list-view control's current font.\r
395         {\r
396                 assert(::IsWindow(m_hWnd));\r
397                 return (int)::SendMessage( m_hWnd, LVM_GETSTRINGWIDTH, 0L, (LPARAM)pszString );\r
398         }\r
399 \r
400         inline BOOL CListView::GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const\r
401         // Retrieves information about the rectangle that surrounds a subitem in a list-view control.\r
402         {\r
403                 assert(::IsWindow(m_hWnd));\r
404                 return ListView_GetSubItemRect( m_hWnd, iItem, iSubItem, iCode, &rc );\r
405         }\r
406 \r
407         inline COLORREF CListView::GetTextBkColor( ) const\r
408         // Retrieves the text background color of a list-view control.\r
409         {\r
410                 assert(::IsWindow(m_hWnd));\r
411                 return ListView_GetTextBkColor( m_hWnd );\r
412         }\r
413 \r
414         inline COLORREF CListView::GetTextColor( ) const\r
415         // Retrieves the text color of a list-view control.\r
416         {\r
417                 assert(::IsWindow(m_hWnd));\r
418                 return ListView_GetTextColor( m_hWnd );\r
419         }\r
420 \r
421         inline CToolTip* CListView::GetToolTips( ) const\r
422         // Retrieves the ToolTip control that the list-view control uses to display ToolTips.\r
423         {\r
424                 assert(::IsWindow(m_hWnd));\r
425                 return(CToolTip*)FromHandle(ListView_GetToolTips( m_hWnd ) );\r
426         }\r
427 \r
428         inline int CListView::GetTopIndex( ) const\r
429         // Retrieves the index of the topmost visible item when in list or report view.\r
430         {\r
431                 assert(::IsWindow(m_hWnd));\r
432                 return ListView_GetTopIndex( m_hWnd );\r
433         }\r
434 \r
435         inline BOOL CListView::GetViewRect( CRect& rc ) const\r
436         // Retrieves the bounding rectangle of all items in the list-view control.\r
437         {\r
438                 assert(::IsWindow(m_hWnd));\r
439                 return ListView_GetViewRect( m_hWnd, &rc );\r
440         }\r
441 \r
442         inline void CListView::GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const\r
443         // Retrieves the working areas from a list-view control.\r
444         {\r
445                 assert(::IsWindow(m_hWnd));\r
446                 ListView_GetWorkAreas( m_hWnd, iWorkAreas, pRectArray );\r
447         }\r
448 \r
449         inline BOOL CListView::SetBkColor( COLORREF clrBk ) const\r
450         // Sets the background color of a list-view control.\r
451         {\r
452                 assert(::IsWindow(m_hWnd));\r
453                 return ListView_SetBkColor( m_hWnd, clrBk );\r
454         }\r
455 \r
456         inline BOOL CListView::SetBkImage( LVBKIMAGE& lvbkImage ) const\r
457         // Sets the background image in a list-view control.\r
458         {\r
459                 assert(::IsWindow(m_hWnd));\r
460                 return ListView_SetBkImage( m_hWnd, &lvbkImage );\r
461         }\r
462 \r
463         inline BOOL CListView::SetCallbackMask( UINT nMask ) const\r
464         // Changes the callback mask for a list-view control.\r
465         {\r
466                 assert(::IsWindow(m_hWnd));\r
467                 return ListView_SetCallbackMask( m_hWnd, nMask );\r
468         }\r
469 \r
470         inline void CListView::SetCheckState( int iItem, BOOL fCheck /*= TRUE*/ ) const\r
471         // Used to select or deselect an item in a list-view control.\r
472         // This macro should only be used for list-view controls with the LVS_EX_CHECKBOXES style.\r
473         {\r
474                 assert(::IsWindow(m_hWnd));\r
475                 ListView_SetItemState(m_hWnd, iItem, INDEXTOSTATEIMAGEMASK((fCheck==TRUE)?2:1),LVIS_STATEIMAGEMASK);\r
476         }\r
477 \r
478         inline BOOL CListView::SetColumn( int iCol, const LVCOLUMN& Column ) const\r
479         // Sets the attributes of a list-view column.\r
480         {\r
481                 assert(::IsWindow(m_hWnd));\r
482                 return ListView_SetColumn( m_hWnd, iCol, &Column );\r
483         }\r
484 \r
485         inline BOOL CListView::SetColumnOrderArray( int iCount, LPINT piArray ) const\r
486         // Sets the left-to-right order of columns in a list-view control.\r
487         {\r
488                 assert(::IsWindow(m_hWnd));\r
489                 return ListView_SetColumnOrderArray( m_hWnd, iCount, piArray );\r
490         }\r
491 \r
492         inline BOOL CListView::SetColumnWidth( int iCol, int cx ) const\r
493         // Used to change the width of a column in report view or the width of all columns in list-view mode.\r
494         {\r
495                 assert(::IsWindow(m_hWnd));\r
496                 return ListView_SetColumnWidth( m_hWnd, iCol, cx );\r
497         }\r
498 \r
499         inline DWORD CListView::SetExtendedStyle( DWORD dwNewStyle ) const\r
500         // Sets extended styles for list-view controls.\r
501         {\r
502                 assert(::IsWindow(m_hWnd));\r
503                 return ListView_SetExtendedListViewStyle( m_hWnd, dwNewStyle );\r
504         }\r
505 \r
506         inline HCURSOR CListView::SetHotCursor( HCURSOR hCursor ) const\r
507         // Sets the HCURSOR that the list-view control uses when the pointer is\r
508         // over an item while hot tracking is enabled.\r
509         {\r
510                 assert(::IsWindow(m_hWnd));\r
511                 return ListView_SetHotCursor( m_hWnd, hCursor );\r
512         }\r
513 \r
514         inline int CListView::SetHotItem( int nIndex ) const\r
515         // Sets the hot item in a list-view control.\r
516         {\r
517                 assert(::IsWindow(m_hWnd));\r
518                 return ListView_SetHotItem( m_hWnd, nIndex );\r
519         }\r
520 \r
521         inline DWORD CListView::SetHoverTime( DWORD dwHoverTime /*= (DWORD)-1*/ ) const\r
522         // Sets the amount of time that the mouse cursor must hover over an item before it is selected.\r
523         {\r
524                 assert(::IsWindow(m_hWnd));\r
525                 return ListView_SetHoverTime( m_hWnd, dwHoverTime );\r
526         }\r
527 \r
528         inline CSize CListView::SetIconSpacing( int cx, int cy ) const\r
529         // Sets the spacing between icons in list-view controls set to the LVS_ICON style.\r
530         {\r
531                 assert(::IsWindow(m_hWnd));\r
532                 return CSize( ListView_SetIconSpacing( m_hWnd, cx, cy ) );\r
533         }\r
534 \r
535         inline CSize CListView::SetIconSpacing( CSize sz ) const\r
536         // Sets the spacing between icons in list-view controls set to the LVS_ICON style.\r
537         {\r
538                 assert(::IsWindow(m_hWnd));\r
539                 return CSize( ListView_SetIconSpacing( m_hWnd, sz.cx, sz.cy ) );\r
540         }\r
541 \r
542         inline HIMAGELIST CListView::SetImageList( HIMAGELIST himl, int iImageListType ) const\r
543         // Assigns an image list to a list-view control.\r
544         {\r
545                 assert(::IsWindow(m_hWnd));\r
546                 return ListView_SetImageList( m_hWnd, himl, iImageListType );\r
547         }\r
548 \r
549         inline BOOL CListView::SetItem( LVITEM& Item ) const\r
550         // Sets some or all of a list-view item's attributes.\r
551 \r
552         // The declaration for TVITEM:\r
553         //      typedef struct _LVITEM {\r
554         //              UINT mask;\r
555         //              int iItem;\r
556         //              int iSubItem;\r
557         //              UINT state;\r
558         //              UINT stateMask;\r
559         //              LPTSTR pszText;\r
560         //              int cchTextMax;\r
561     //          int iImage;\r
562         //              LPARAM lParam;\r
563         // } LVITEM, *LVITEM&;\r
564         {\r
565                 assert(::IsWindow(m_hWnd));\r
566                 return ListView_SetItem( m_hWnd, &Item );\r
567         }\r
568 \r
569         inline BOOL CListView::SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,\r
570                                         UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const\r
571         // Sets some or all of a list-view item's attributes.\r
572         {\r
573                 assert(::IsWindow(m_hWnd));\r
574 \r
575                 LVITEM lvi = {0};\r
576                 lvi.iItem = iItem;\r
577                 lvi.iSubItem = iSubItem;\r
578                 lvi.mask = nMask;\r
579                 lvi.pszText = (LPTSTR)pszText;\r
580                 lvi.iImage = iImage;\r
581                 lvi.state = nState;\r
582                 lvi.stateMask = nStateMask;\r
583                 lvi.lParam = lParam;\r
584                 lvi.iIndent = iIndent;\r
585 \r
586                 return ListView_SetItem( m_hWnd, &lvi);\r
587         }\r
588 \r
589         inline void CListView::SetItemCount( int iCount ) const\r
590         // Causes the list-view control to allocate memory for the specified number of items.\r
591         {\r
592                 assert(::IsWindow(m_hWnd));\r
593                 ListView_SetItemCount( m_hWnd, iCount );\r
594         }\r
595 \r
596         inline void CListView::SetItemCountEx( int iCount, DWORD dwFlags /*= LVSICF_NOINVALIDATEALL*/ ) const\r
597         // Sets the virtual number of items in a virtual list view.\r
598         {\r
599                 assert(::IsWindow(m_hWnd));\r
600                 ListView_SetItemCountEx( m_hWnd, iCount, dwFlags );\r
601         }\r
602 \r
603         inline BOOL CListView::SetItemData( int iItem, DWORD_PTR dwData ) const\r
604         // Sets the value(lParam) specific to the item.\r
605         {\r
606                 assert(::IsWindow(m_hWnd));\r
607 \r
608                 LVITEM lvi = {0};\r
609                 lvi.iItem = iItem;\r
610                 lvi.lParam = dwData;\r
611                 lvi.mask = LVIF_PARAM;\r
612                 return ListView_SetItem(m_hWnd, &lvi);\r
613         }\r
614 \r
615         inline BOOL CListView::SetItemPosition( int iItem, CPoint& pt ) const\r
616         // Moves an item to a specified position in a list-view control (in icon or small icon view).\r
617         {\r
618                 assert(::IsWindow(m_hWnd));\r
619                 return ListView_SetItemPosition( m_hWnd, iItem, pt.x, pt.y );\r
620         }\r
621 \r
622         inline BOOL CListView::SetItemState( int iItem, LVITEM& Item ) const\r
623         // Changes the state of an item in a list-view control.\r
624 \r
625         // Possible values of nMask:\r
626         // LVIS_CUT                             The item is marked for a cut-and-paste operation.\r
627         // LVIS_DROPHILITED             The item is highlighted as a drag-and-drop target.\r
628         // LVIS_FOCUSED                 The item has the focus, so it is surrounded by a standard focus rectangle.\r
629         // LVIS_SELECTED                The item is selected.\r
630         // LVIS_OVERLAYMASK             Use this mask to retrieve the item's overlay image index.\r
631         // LVIS_STATEIMAGEMASK  Use this mask to retrieve the item's state image index.\r
632         {\r
633                 assert(::IsWindow(m_hWnd));\r
634                 return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, (WPARAM)iItem, (LPARAM)&Item);\r
635         }\r
636 \r
637     inline void CListView::SetItemState( int iItem, UINT nState, UINT nMask ) const\r
638         // Changes the state of an item in a list-view control.\r
639         {\r
640                 assert(::IsWindow(m_hWnd));\r
641                 ListView_SetItemState(m_hWnd, iItem, nState, nMask);\r
642         }\r
643 \r
644         inline void CListView::SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const\r
645         // Sets the text color of a list-view control.\r
646         {\r
647                 assert(::IsWindow(m_hWnd));\r
648                 ListView_SetItemText(m_hWnd, iItem, iSubItem, (LPTSTR)pszText );\r
649         }\r
650 \r
651         inline int CListView::SetSelectionMark( int iIndex ) const\r
652         // Sets the selection mark in a list-view control.\r
653         {\r
654                 assert(::IsWindow(m_hWnd));\r
655                 return ListView_SetSelectionMark( m_hWnd, iIndex );\r
656         }\r
657 \r
658         inline BOOL CListView::SetTextBkColor( COLORREF clrBkText ) const\r
659         // Sets the background color of text in a list-view control.\r
660         {\r
661                 assert(::IsWindow(m_hWnd));\r
662                 return ListView_SetTextBkColor( m_hWnd, clrBkText );\r
663         }\r
664 \r
665         inline BOOL CListView::SetTextColor( COLORREF clrText ) const\r
666         // Sets the text color of a list-view control.\r
667         {\r
668                 assert(::IsWindow(m_hWnd));\r
669                 return ListView_SetTextColor( m_hWnd, clrText );\r
670         }\r
671 \r
672         inline CToolTip* CListView::SetToolTips( CToolTip* pToolTip ) const\r
673         // Sets the ToolTip control that the list-view control will use to display ToolTips.\r
674         {\r
675                 assert(::IsWindow(m_hWnd));\r
676                 assert(pToolTip);\r
677 \r
678                 HWND hToolTip = pToolTip? pToolTip->GetHwnd() : 0;\r
679                 return (CToolTip*) FromHandle( (HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hToolTip, 0L) );\r
680         }\r
681 \r
682         inline void CListView::SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const\r
683         // Sets the working area within a list-view control.\r
684         {\r
685                 assert(::IsWindow(m_hWnd));\r
686                 ListView_SetWorkAreas( m_hWnd, nWorkAreas, pRectArray );\r
687         }\r
688 \r
689         inline int CListView::SubItemHitTest( LVHITTESTINFO& htInfo ) const\r
690         // Determines which list-view item or subitem is located at a given position.\r
691         {\r
692                 assert(::IsWindow(m_hWnd));\r
693                 return ListView_SubItemHitTest( m_hWnd, &htInfo );\r
694         }\r
695 \r
696         // Operations\r
697 \r
698         inline BOOL CListView::Arrange( UINT nCode ) const\r
699         // Arranges items in icon view.\r
700         {\r
701                 assert(::IsWindow(m_hWnd));\r
702                 return ListView_Arrange( m_hWnd, nCode );\r
703         }\r
704 \r
705         inline HIMAGELIST CListView::CreateDragImage( int iItem, CPoint& pt ) const\r
706         // Creates a drag image list for the specified item.\r
707         {\r
708                 assert(::IsWindow(m_hWnd));\r
709                 return ListView_CreateDragImage( m_hWnd, iItem, &pt );\r
710         }\r
711 \r
712         inline BOOL CListView::DeleteAllItems( ) const\r
713         // ListView_DeleteAllItems\r
714         {\r
715                 assert(::IsWindow(m_hWnd));\r
716                 return ListView_DeleteAllItems( m_hWnd );\r
717         }\r
718 \r
719         inline BOOL CListView::DeleteColumn( int iCol ) const\r
720         // Removes a column from a list-view control.\r
721         {\r
722                 assert(::IsWindow(m_hWnd));\r
723                 return ListView_DeleteColumn( m_hWnd, iCol );\r
724         }\r
725 \r
726         inline BOOL CListView::DeleteItem( int iItem ) const\r
727         // Removes an item from a list-view control.\r
728         {\r
729                 assert(::IsWindow(m_hWnd));\r
730                 return ListView_DeleteItem( m_hWnd, iItem );\r
731         }\r
732 \r
733         inline CEdit* CListView::EditLabel( int iItem ) const\r
734         // Begins in-place editing of the specified list-view item's text.\r
735         {\r
736                 assert(::IsWindow(m_hWnd));\r
737                 return (CEdit*)FromHandle( ListView_EditLabel( m_hWnd, iItem ) );\r
738         }\r
739 \r
740         inline BOOL CListView::EnsureVisible( int iItem, BOOL fPartialOK ) const\r
741         // Ensures that a list-view item is either entirely or partially visible,\r
742         // scrolling the list-view control if necessary.\r
743         {\r
744                 assert(::IsWindow(m_hWnd));\r
745                 return (BOOL)SendMessage(LVM_ENSUREVISIBLE, (WPARAM)iItem, (LPARAM)fPartialOK );\r
746         }\r
747 \r
748         inline int CListView::FindItem( LVFINDINFO& FindInfo, int iStart /*= -1*/ ) const\r
749         // Searches for a list-view item with the specified characteristics.\r
750         {\r
751                 assert(::IsWindow(m_hWnd));\r
752                 return ListView_FindItem( m_hWnd, iStart, &FindInfo );\r
753         }\r
754 \r
755         inline int CListView::HitTest( LVHITTESTINFO& HitTestInfo ) const\r
756         // Determines which list-view item, if any, is at a specified position.\r
757         {\r
758                 assert(::IsWindow(m_hWnd));\r
759                 return ListView_HitTest( m_hWnd, &HitTestInfo );\r
760         }\r
761 \r
762     inline int CListView::HitTest( CPoint pt, UINT* pFlags /*= NULL*/ ) const\r
763         // Determines which list-view item, if any, is at a specified position.\r
764         {\r
765                 assert(::IsWindow(m_hWnd));\r
766 \r
767                 LVHITTESTINFO hti = {0};\r
768                 hti.flags = *pFlags;\r
769                 hti.pt = pt;\r
770                 return ListView_HitTest( m_hWnd, &hti );\r
771         }\r
772 \r
773         inline int CListView::InsertColumn( int iCol, const LVCOLUMN& Column ) const\r
774         // Inserts a new column in a list-view control.\r
775         {\r
776                 assert(::IsWindow(m_hWnd));\r
777                 return ListView_InsertColumn( m_hWnd, iCol, &Column );\r
778         }\r
779 \r
780     inline int CListView::InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat /*= LVCFMT_LEFT*/,\r
781                                                 int iWidth /*= -1*/, int iSubItem /*= -1*/ ) const\r
782         // Inserts a new column in a list-view control.\r
783         {\r
784                 assert(::IsWindow(m_hWnd));\r
785 \r
786                 LVCOLUMN lvc = {0};\r
787                 lvc.mask = LVCF_TEXT|LVCF_ORDER|LVCF_FMT;\r
788                 if (-1 != iWidth)\r
789                 {\r
790                         lvc.mask |= LVCF_WIDTH; \r
791                         lvc.cx = iWidth; \r
792                 }\r
793                 if (-1 !=  iSubItem)\r
794                 {\r
795                         lvc.mask |= LVCF_SUBITEM; \r
796                         lvc.iSubItem = iSubItem;\r
797                 }\r
798 \r
799                 lvc.iOrder = iCol;\r
800                 lvc.pszText = (LPTSTR)pszColumnHeading;\r
801                 lvc.fmt = iFormat;\r
802                 lvc.iSubItem = iSubItem;\r
803                 return ListView_InsertColumn( m_hWnd, iCol, &lvc );\r
804         }\r
805 \r
806         inline int CListView::InsertItem( const LVITEM& Item ) const\r
807         // Inserts a new item in a list-view control.\r
808         {\r
809                 assert(::IsWindow(m_hWnd));\r
810                 return ListView_InsertItem( m_hWnd, &Item );\r
811         }\r
812 \r
813     inline int CListView::InsertItem( int iItem, LPCTSTR pszText ) const\r
814         // Inserts a new item in a list-view control.\r
815         {\r
816                 assert(::IsWindow(m_hWnd));\r
817 \r
818                 LVITEM lvi = {0};\r
819                 lvi.iItem = iItem;\r
820                 lvi.pszText = (LPTSTR)pszText;\r
821                 lvi.mask = LVIF_TEXT;\r
822                 return ListView_InsertItem( m_hWnd, &lvi );\r
823         }\r
824 \r
825     inline int CListView::InsertItem( int iItem, LPCTSTR pszText, int iImage ) const\r
826         // Inserts a new item in a list-view control.\r
827         {\r
828                 assert(::IsWindow(m_hWnd));\r
829 \r
830                 LVITEM lvi = {0};\r
831                 lvi.iItem = iItem;\r
832                 lvi.pszText = (LPTSTR)pszText;\r
833                 lvi.iImage = iImage;\r
834                 lvi.mask = LVIF_TEXT | LVIF_IMAGE;\r
835                 return ListView_InsertItem( m_hWnd, &lvi );\r
836         }\r
837 \r
838         inline BOOL CListView::RedrawItems( int iFirst, int iLast ) const\r
839         // Forces a list-view control to redraw a range of items.\r
840         {\r
841                 assert(::IsWindow(m_hWnd));\r
842                 return ListView_RedrawItems( m_hWnd, iFirst, iLast );\r
843         }\r
844 \r
845         inline BOOL CListView::Scroll( CSize sz ) const\r
846         // Scrolls the content of a list-view control.\r
847         {\r
848                 assert(::IsWindow(m_hWnd));\r
849                 return ListView_Scroll( m_hWnd, sz.cx, sz.cy );\r
850         }\r
851 \r
852         inline BOOL CListView::SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const\r
853         // Uses an application-defined comparison function to sort the items of a list-view control.\r
854         {\r
855                 assert(::IsWindow(m_hWnd));\r
856                 return ListView_SortItems( m_hWnd, pfnCompare, dwData );\r
857         }\r
858 \r
859         inline BOOL CListView::Update( int iItem ) const\r
860         // Updates a list-view item. If the list-view control has the LVS_AUTOARRANGE style,\r
861         // the list-view control is rearranged.\r
862         {\r
863                 assert(::IsWindow(m_hWnd));\r
864                 return ListView_Update( m_hWnd, iItem );\r
865         }\r
866 \r
867 } // namespace Win32xx\r
868 \r
869 #endif // #ifndef _WIN32XX_LISTVIEW_H_\r
870 \r

UCC git Repository :: git.ucc.asn.au