--- /dev/null
+// Win32++ Version 7.3\r
+// Released: 30th November 2011\r
+//\r
+// David Nash\r
+// url: https://sourceforge.net/projects/win32-framework\r
+//\r
+//\r
+// Copyright (c) 2005-2011 David Nash\r
+//\r
+// Permission is hereby granted, free of charge, to\r
+// any person obtaining a copy of this software and\r
+// associated documentation files (the "Software"),\r
+// to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify,\r
+// merge, publish, distribute, sublicense, and/or sell\r
+// copies of the Software, and to permit persons to whom\r
+// the Software is furnished to do so, subject to the\r
+// following conditions:\r
+//\r
+// The above copyright notice and this permission notice\r
+// shall be included in all copies or substantial portions\r
+// of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF\r
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\r
+// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\r
+// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR\r
+// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\r
+// OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#ifndef _WIN32XX_LISTVIEW_H_\r
+#define _WIN32XX_LISTVIEW_H_\r
+\r
+#include "wincore.h"\r
+#include "commctrl.h"\r
+\r
+namespace Win32xx\r
+{\r
+\r
+ class CListView : public CWnd\r
+ {\r
+ public:\r
+ CListView() {}\r
+ virtual ~CListView() {}\r
+ virtual void PreRegisterClass(WNDCLASS &wc);\r
+\r
+ // Attributes\r
+ CSize ApproximateViewRect(CSize sz = CSize(-1, -1), int iCount = -1) const;\r
+ COLORREF GetBkColor( ) const;\r
+ BOOL GetBkImage( LVBKIMAGE& lvbkImage ) const;\r
+ UINT GetCallbackMask( ) const;\r
+ BOOL GetCheckState( UINT nItem ) const;\r
+ BOOL GetColumn( int iCol, LVCOLUMN& Column ) const;\r
+ BOOL GetColumnOrderArray( LPINT piArray, int iCount = -1 );\r
+ int GetColumnWidth( int iCol ) const;\r
+ int GetCountPerPage( ) const;\r
+ CEdit* GetEditControl( ) const;\r
+ DWORD GetExtendedStyle( ) const;\r
+ CHeader* GetHeader( ) const;\r
+ HCURSOR GetHotCursor( );\r
+ int GetHotItem( ) const;\r
+ DWORD GetHoverTime( ) const;\r
+ HIMAGELIST GetImageList( int nImageType ) const;\r
+ BOOL GetItem( LVITEM& lvItem ) const;\r
+ int GetItemCount( ) const;\r
+ DWORD_PTR GetItemData( int iItem ) const;\r
+ BOOL GetItemPosition( int iItem, CPoint& pt ) const;\r
+ BOOL GetItemRect( int iItem, CRect& rc, UINT nCode ) const;\r
+ UINT GetItemState( int iItem, UINT nMask ) const;\r
+ CString GetItemText( int iItem, int iSubItem, UINT nTextMax = 260 ) const;\r
+ int GetNextItem( int iItem, int iFlags ) const;\r
+ UINT GetNumberOfWorkAreas( ) const;\r
+ BOOL GetOrigin( CPoint& pt ) const;\r
+ UINT GetSelectedCount( ) const;\r
+ int GetSelectionMark( ) const;\r
+ int GetStringWidth( LPCTSTR pszString ) const;\r
+ BOOL GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const;\r
+ COLORREF GetTextBkColor( ) const;\r
+ COLORREF GetTextColor( ) const;\r
+ CToolTip* GetToolTips( ) const;\r
+ int GetTopIndex( ) const;\r
+ BOOL GetViewRect( CRect& rc ) const;\r
+ void GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const;\r
+ BOOL SetBkColor( COLORREF clrBk ) const;\r
+ BOOL SetBkImage( LVBKIMAGE& plvbkImage ) const;\r
+ BOOL SetCallbackMask( UINT nMask ) const;\r
+ void SetCheckState( int iItem, BOOL fCheck = TRUE ) const;\r
+ BOOL SetColumn( int iCol, const LVCOLUMN& pColumn ) const;\r
+ BOOL SetColumnOrderArray( int iCount, LPINT piArray ) const;\r
+ BOOL SetColumnWidth( int iCol, int cx ) const;\r
+ DWORD SetExtendedStyle( DWORD dwNewStyle ) const;\r
+ HCURSOR SetHotCursor( HCURSOR hCursor ) const;\r
+ int SetHotItem( int nIndex ) const;\r
+ DWORD SetHoverTime( DWORD dwHoverTime = (DWORD)-1 ) const;\r
+ CSize SetIconSpacing( int cx, int cy ) const;\r
+ CSize SetIconSpacing( CSize sz ) const;\r
+ HIMAGELIST SetImageList( HIMAGELIST himl, int iImageListType ) const;\r
+ BOOL SetItem( LVITEM& pItem ) const;\r
+ BOOL SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,\r
+ UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const;\r
+ void SetItemCount( int iCount ) const;\r
+ void SetItemCountEx( int iCount, DWORD dwFlags = LVSICF_NOINVALIDATEALL ) const;\r
+ BOOL SetItemData( int iItem, DWORD_PTR dwData ) const;\r
+ BOOL SetItemPosition( int iItem, CPoint& pt ) const;\r
+ BOOL SetItemState( int iItem, LVITEM& Item ) const;\r
+ void SetItemState( int iItem, UINT nState, UINT nMask ) const;\r
+ void SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const;\r
+ int SetSelectionMark( int iIndex ) const;\r
+ BOOL SetTextBkColor( COLORREF clrBkText ) const;\r
+ BOOL SetTextColor( COLORREF clrText ) const;\r
+ CToolTip* SetToolTips ( CToolTip* pToolTip ) const;\r
+ void SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const;\r
+ int SubItemHitTest( LVHITTESTINFO& htInfo ) const;\r
+\r
+ // Operations\r
+ BOOL Arrange( UINT nCode ) const;\r
+ HIMAGELIST CreateDragImage( int iItem, CPoint& pt ) const;\r
+ BOOL DeleteAllItems( ) const;\r
+ BOOL DeleteColumn( int iCol ) const;\r
+ BOOL DeleteItem( int iItem ) const;\r
+ CEdit* EditLabel( int iItem ) const;\r
+ BOOL EnsureVisible( int iItem, BOOL fPartialOK ) const;\r
+ int FindItem( LVFINDINFO& FindInfo, int iStart = -1 ) const;\r
+ int HitTest( LVHITTESTINFO& HitTestInfo ) const;\r
+ int HitTest( CPoint pt, UINT* pFlags = NULL ) const;\r
+ int InsertColumn( int iCol, const LVCOLUMN& pColumn ) const;\r
+ int InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat = LVCFMT_LEFT,\r
+ int iWidth = -1, int iSubItem = -1 ) const;\r
+ int InsertItem( const LVITEM& pItem ) const;\r
+ int InsertItem( int iItem, LPCTSTR pszText ) const;\r
+ int InsertItem( int iItem, LPCTSTR pszText, int iImage ) const;\r
+ BOOL RedrawItems( int iFirst, int iLast ) const;\r
+ BOOL Scroll( CSize sz ) const;\r
+ BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const;\r
+ BOOL Update( int iItem ) const;\r
+\r
+ private:\r
+ CListView(const CListView&); // Disable copy construction\r
+ CListView& operator = (const CListView&); // Disable assignment operator\r
+ };\r
+\r
+}\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+namespace Win32xx\r
+{\r
+\r
+ inline void CListView::PreRegisterClass(WNDCLASS &wc)\r
+ {\r
+ // Set the Window Class\r
+ wc.lpszClassName = WC_LISTVIEW;\r
+ }\r
+\r
+ inline CSize CListView::ApproximateViewRect(CSize sz /*= CSize(-1, -1)*/, int iCount /* = -1*/) const\r
+ // Calculates the approximate width and height required to display a given number of items.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return CSize( ListView_ApproximateViewRect( m_hWnd, sz.cx, sz.cy, iCount ) );\r
+ }\r
+\r
+ inline COLORREF CListView::GetBkColor( ) const\r
+ // Retrieves the background color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetBkColor( m_hWnd );\r
+ }\r
+\r
+ inline BOOL CListView::GetBkImage( LVBKIMAGE& lvbkImage ) const\r
+ // Retrieves the background image in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetBkImage( m_hWnd, &lvbkImage );\r
+ }\r
+\r
+ inline UINT CListView::GetCallbackMask( ) const\r
+ // Retrieves the callback mask for a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetCallbackMask( m_hWnd );\r
+ }\r
+\r
+ inline BOOL CListView::GetCheckState( UINT nItem ) const\r
+ // Determines if an item in a list-view control is selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetCheckState( m_hWnd, nItem );\r
+ }\r
+\r
+ inline BOOL CListView::GetColumn( int iCol, LVCOLUMN& Column ) const\r
+ // Retrieves the attributes of a list-view control's column.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetColumn( m_hWnd, iCol, &Column );\r
+ }\r
+\r
+ inline BOOL CListView::GetColumnOrderArray( LPINT piArray, int iCount /*= -1*/ )\r
+ // Retrieves the current left-to-right order of columns in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetColumnOrderArray( m_hWnd, iCount, piArray );\r
+ }\r
+\r
+ inline int CListView::GetColumnWidth( int iCol ) const\r
+ // Retrieves the width of a column in report or list view.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetColumnWidth( m_hWnd, iCol );\r
+ }\r
+\r
+ inline int CListView::GetCountPerPage( ) const\r
+ // Calculates the number of items that can fit vertically in the visible area of a\r
+ // list-view control when in list or report view. Only fully visible items are counted.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetCountPerPage( m_hWnd );\r
+ }\r
+\r
+ inline CEdit* CListView::GetEditControl( ) const\r
+ // Retrieves the handle to the edit control being used to edit a list-view item's text.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (CEdit*)FromHandle(ListView_GetEditControl( m_hWnd ));\r
+ }\r
+\r
+ inline DWORD CListView::GetExtendedStyle( ) const\r
+ // Retrieves the extended styles that are currently in use for a given list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetExtendedListViewStyle( m_hWnd );\r
+ }\r
+\r
+ inline CHeader* CListView::GetHeader( ) const\r
+ // Retrieves the handle to the header control used by a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (CHeader*)FromHandle(ListView_GetHeader( m_hWnd ));\r
+ }\r
+\r
+ inline HCURSOR CListView::GetHotCursor( )\r
+ // Retrieves the HCURSOR used when the pointer is over an item while hot tracking is enabled.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetHotCursor( m_hWnd );\r
+ }\r
+\r
+ inline int CListView::GetHotItem( ) const\r
+ // Retrieves the index of the hot item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetHotItem( m_hWnd );\r
+ }\r
+\r
+ inline DWORD CListView::GetHoverTime( ) const\r
+ // Retrieves the amount of time that the mouse cursor must hover over an item before it is selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetHoverTime( m_hWnd );\r
+ }\r
+\r
+ inline HIMAGELIST CListView::GetImageList( int nImageType ) const\r
+ // Retrieves the handle to an image list used for drawing list-view items.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetImageList( m_hWnd, nImageType );\r
+ }\r
+\r
+ inline BOOL CListView::GetItem( LVITEM& Item ) const\r
+ // Retrieves some or all of a list-view item's attributes.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetItem( m_hWnd, &Item );\r
+ }\r
+\r
+ inline int CListView::GetItemCount( ) const\r
+ // Retrieves the number of items in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetItemCount( m_hWnd );\r
+ }\r
+\r
+ inline DWORD_PTR CListView::GetItemData( int iItem ) const\r
+ // Retrieves the value(lParam) specific to the item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.mask = LVIF_PARAM;\r
+ ListView_GetItem(m_hWnd, &lvi);\r
+ return lvi.lParam;\r
+ }\r
+\r
+ inline BOOL CListView::GetItemPosition( int iItem, CPoint& pt ) const\r
+ // Retrieves the position of a list-view item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetItemPosition( m_hWnd, iItem, &pt );\r
+ }\r
+\r
+ inline BOOL CListView::GetItemRect( int iItem, CRect& rc, UINT nCode ) const\r
+ // Retrieves the bounding rectangle for all or part of an item in the current view.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetItemRect( m_hWnd, iItem, &rc, nCode );\r
+ }\r
+\r
+ inline UINT CListView::GetItemState( int iItem, UINT nMask ) const\r
+ // Retrieves the state of a list-view item.\r
+\r
+ // Possible values of nMask:\r
+ // LVIS_CUT The item is marked for a cut-and-paste operation.\r
+ // LVIS_DROPHILITED The item is highlighted as a drag-and-drop target.\r
+ // LVIS_FOCUSED The item has the focus, so it is surrounded by a standard focus rectangle.\r
+ // LVIS_SELECTED The item is selected.\r
+ // LVIS_OVERLAYMASK Use this mask to retrieve the item's overlay image index.\r
+ // LVIS_STATEIMAGEMASK Use this mask to retrieve the item's state image index.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetItemState( m_hWnd, iItem, nMask );\r
+ }\r
+\r
+ inline CString CListView::GetItemText( int iItem, int iSubItem, UINT nTextMax /* = 260 */ ) const\r
+ // Retrieves the text of a list-view item.\r
+ // Note: Although the list-view control allows any length string to be stored\r
+ // as item text, only the first 260 characters are displayed.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ CString t;\r
+ if (nTextMax > 0)\r
+ {\r
+ std::vector<TCHAR> vTChar(nTextMax +1, _T('\0'));\r
+ TCHAR* pszText = &vTChar.front();\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.iSubItem = iSubItem;\r
+ lvi.mask = LVIF_TEXT;\r
+ lvi.cchTextMax = nTextMax;\r
+ lvi.pszText = pszText;\r
+ ListView_GetItem( m_hWnd, &lvi );\r
+ t = lvi.pszText;\r
+ }\r
+ return t;\r
+ }\r
+\r
+ inline int CListView::GetNextItem( int iItem, int iFlags ) const\r
+ // Searches for a list-view item that has the specified properties and\r
+ // bears the specified relationship to a specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetNextItem( m_hWnd, iItem, iFlags );\r
+ }\r
+\r
+ inline UINT CListView::GetNumberOfWorkAreas( ) const\r
+ // Retrieves the working areas from a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ UINT nWorkAreas = 0;\r
+ ListView_GetWorkAreas( m_hWnd, nWorkAreas, NULL );\r
+ return nWorkAreas;\r
+ }\r
+\r
+ inline BOOL CListView::GetOrigin( CPoint& pt ) const\r
+ // Retrieves the current view origin for a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetOrigin( m_hWnd, &pt );\r
+ }\r
+\r
+ inline UINT CListView::GetSelectedCount( ) const\r
+ // Determines the number of selected items in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)::SendMessage( m_hWnd, LVM_GETSELECTEDCOUNT, 0L, 0L );\r
+ }\r
+\r
+ inline int CListView::GetSelectionMark( ) const\r
+ // Retrieves the selection mark from a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)::SendMessage( m_hWnd, LVM_GETSELECTIONMARK, 0L, 0L );\r
+ }\r
+\r
+ inline int CListView::GetStringWidth( LPCTSTR pszString ) const\r
+ // Determines the width of a specified string using the specified list-view control's current font.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)::SendMessage( m_hWnd, LVM_GETSTRINGWIDTH, 0L, (LPARAM)pszString );\r
+ }\r
+\r
+ inline BOOL CListView::GetSubItemRect( int iItem, int iSubItem, int iCode, CRect& rc ) const\r
+ // Retrieves information about the rectangle that surrounds a subitem in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetSubItemRect( m_hWnd, iItem, iSubItem, iCode, &rc );\r
+ }\r
+\r
+ inline COLORREF CListView::GetTextBkColor( ) const\r
+ // Retrieves the text background color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetTextBkColor( m_hWnd );\r
+ }\r
+\r
+ inline COLORREF CListView::GetTextColor( ) const\r
+ // Retrieves the text color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetTextColor( m_hWnd );\r
+ }\r
+\r
+ inline CToolTip* CListView::GetToolTips( ) const\r
+ // Retrieves the ToolTip control that the list-view control uses to display ToolTips.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return(CToolTip*)FromHandle(ListView_GetToolTips( m_hWnd ) );\r
+ }\r
+\r
+ inline int CListView::GetTopIndex( ) const\r
+ // Retrieves the index of the topmost visible item when in list or report view.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetTopIndex( m_hWnd );\r
+ }\r
+\r
+ inline BOOL CListView::GetViewRect( CRect& rc ) const\r
+ // Retrieves the bounding rectangle of all items in the list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_GetViewRect( m_hWnd, &rc );\r
+ }\r
+\r
+ inline void CListView::GetWorkAreas( int iWorkAreas, LPRECT pRectArray ) const\r
+ // Retrieves the working areas from a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_GetWorkAreas( m_hWnd, iWorkAreas, pRectArray );\r
+ }\r
+\r
+ inline BOOL CListView::SetBkColor( COLORREF clrBk ) const\r
+ // Sets the background color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetBkColor( m_hWnd, clrBk );\r
+ }\r
+\r
+ inline BOOL CListView::SetBkImage( LVBKIMAGE& lvbkImage ) const\r
+ // Sets the background image in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetBkImage( m_hWnd, &lvbkImage );\r
+ }\r
+\r
+ inline BOOL CListView::SetCallbackMask( UINT nMask ) const\r
+ // Changes the callback mask for a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetCallbackMask( m_hWnd, nMask );\r
+ }\r
+\r
+ inline void CListView::SetCheckState( int iItem, BOOL fCheck /*= TRUE*/ ) const\r
+ // Used to select or deselect an item in a list-view control.\r
+ // This macro should only be used for list-view controls with the LVS_EX_CHECKBOXES style.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetItemState(m_hWnd, iItem, INDEXTOSTATEIMAGEMASK((fCheck==TRUE)?2:1),LVIS_STATEIMAGEMASK);\r
+ }\r
+\r
+ inline BOOL CListView::SetColumn( int iCol, const LVCOLUMN& Column ) const\r
+ // Sets the attributes of a list-view column.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetColumn( m_hWnd, iCol, &Column );\r
+ }\r
+\r
+ inline BOOL CListView::SetColumnOrderArray( int iCount, LPINT piArray ) const\r
+ // Sets the left-to-right order of columns in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetColumnOrderArray( m_hWnd, iCount, piArray );\r
+ }\r
+\r
+ inline BOOL CListView::SetColumnWidth( int iCol, int cx ) const\r
+ // Used to change the width of a column in report view or the width of all columns in list-view mode.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetColumnWidth( m_hWnd, iCol, cx );\r
+ }\r
+\r
+ inline DWORD CListView::SetExtendedStyle( DWORD dwNewStyle ) const\r
+ // Sets extended styles for list-view controls.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetExtendedListViewStyle( m_hWnd, dwNewStyle );\r
+ }\r
+\r
+ inline HCURSOR CListView::SetHotCursor( HCURSOR hCursor ) const\r
+ // Sets the HCURSOR that the list-view control uses when the pointer is\r
+ // over an item while hot tracking is enabled.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetHotCursor( m_hWnd, hCursor );\r
+ }\r
+\r
+ inline int CListView::SetHotItem( int nIndex ) const\r
+ // Sets the hot item in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetHotItem( m_hWnd, nIndex );\r
+ }\r
+\r
+ inline DWORD CListView::SetHoverTime( DWORD dwHoverTime /*= (DWORD)-1*/ ) const\r
+ // Sets the amount of time that the mouse cursor must hover over an item before it is selected.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetHoverTime( m_hWnd, dwHoverTime );\r
+ }\r
+\r
+ inline CSize CListView::SetIconSpacing( int cx, int cy ) const\r
+ // Sets the spacing between icons in list-view controls set to the LVS_ICON style.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return CSize( ListView_SetIconSpacing( m_hWnd, cx, cy ) );\r
+ }\r
+\r
+ inline CSize CListView::SetIconSpacing( CSize sz ) const\r
+ // Sets the spacing between icons in list-view controls set to the LVS_ICON style.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return CSize( ListView_SetIconSpacing( m_hWnd, sz.cx, sz.cy ) );\r
+ }\r
+\r
+ inline HIMAGELIST CListView::SetImageList( HIMAGELIST himl, int iImageListType ) const\r
+ // Assigns an image list to a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetImageList( m_hWnd, himl, iImageListType );\r
+ }\r
+\r
+ inline BOOL CListView::SetItem( LVITEM& Item ) const\r
+ // Sets some or all of a list-view item's attributes.\r
+\r
+ // The declaration for TVITEM:\r
+ // typedef struct _LVITEM {\r
+ // UINT mask;\r
+ // int iItem;\r
+ // int iSubItem;\r
+ // UINT state;\r
+ // UINT stateMask;\r
+ // LPTSTR pszText;\r
+ // int cchTextMax;\r
+ // int iImage;\r
+ // LPARAM lParam;\r
+ // } LVITEM, *LVITEM&;\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetItem( m_hWnd, &Item );\r
+ }\r
+\r
+ inline BOOL CListView::SetItem( int iItem, int iSubItem, UINT nMask, LPCTSTR pszText, int iImage,\r
+ UINT nState, UINT nStateMask, LPARAM lParam, int iIndent ) const\r
+ // Sets some or all of a list-view item's attributes.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.iSubItem = iSubItem;\r
+ lvi.mask = nMask;\r
+ lvi.pszText = (LPTSTR)pszText;\r
+ lvi.iImage = iImage;\r
+ lvi.state = nState;\r
+ lvi.stateMask = nStateMask;\r
+ lvi.lParam = lParam;\r
+ lvi.iIndent = iIndent;\r
+\r
+ return ListView_SetItem( m_hWnd, &lvi);\r
+ }\r
+\r
+ inline void CListView::SetItemCount( int iCount ) const\r
+ // Causes the list-view control to allocate memory for the specified number of items.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetItemCount( m_hWnd, iCount );\r
+ }\r
+\r
+ inline void CListView::SetItemCountEx( int iCount, DWORD dwFlags /*= LVSICF_NOINVALIDATEALL*/ ) const\r
+ // Sets the virtual number of items in a virtual list view.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetItemCountEx( m_hWnd, iCount, dwFlags );\r
+ }\r
+\r
+ inline BOOL CListView::SetItemData( int iItem, DWORD_PTR dwData ) const\r
+ // Sets the value(lParam) specific to the item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.lParam = dwData;\r
+ lvi.mask = LVIF_PARAM;\r
+ return ListView_SetItem(m_hWnd, &lvi);\r
+ }\r
+\r
+ inline BOOL CListView::SetItemPosition( int iItem, CPoint& pt ) const\r
+ // Moves an item to a specified position in a list-view control (in icon or small icon view).\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetItemPosition( m_hWnd, iItem, pt.x, pt.y );\r
+ }\r
+\r
+ inline BOOL CListView::SetItemState( int iItem, LVITEM& Item ) const\r
+ // Changes the state of an item in a list-view control.\r
+\r
+ // Possible values of nMask:\r
+ // LVIS_CUT The item is marked for a cut-and-paste operation.\r
+ // LVIS_DROPHILITED The item is highlighted as a drag-and-drop target.\r
+ // LVIS_FOCUSED The item has the focus, so it is surrounded by a standard focus rectangle.\r
+ // LVIS_SELECTED The item is selected.\r
+ // LVIS_OVERLAYMASK Use this mask to retrieve the item's overlay image index.\r
+ // LVIS_STATEIMAGEMASK Use this mask to retrieve the item's state image index.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, (WPARAM)iItem, (LPARAM)&Item);\r
+ }\r
+\r
+ inline void CListView::SetItemState( int iItem, UINT nState, UINT nMask ) const\r
+ // Changes the state of an item in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetItemState(m_hWnd, iItem, nState, nMask);\r
+ }\r
+\r
+ inline void CListView::SetItemText( int iItem, int iSubItem, LPCTSTR pszText ) const\r
+ // Sets the text color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetItemText(m_hWnd, iItem, iSubItem, (LPTSTR)pszText );\r
+ }\r
+\r
+ inline int CListView::SetSelectionMark( int iIndex ) const\r
+ // Sets the selection mark in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetSelectionMark( m_hWnd, iIndex );\r
+ }\r
+\r
+ inline BOOL CListView::SetTextBkColor( COLORREF clrBkText ) const\r
+ // Sets the background color of text in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetTextBkColor( m_hWnd, clrBkText );\r
+ }\r
+\r
+ inline BOOL CListView::SetTextColor( COLORREF clrText ) const\r
+ // Sets the text color of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SetTextColor( m_hWnd, clrText );\r
+ }\r
+\r
+ inline CToolTip* CListView::SetToolTips( CToolTip* pToolTip ) const\r
+ // Sets the ToolTip control that the list-view control will use to display ToolTips.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ assert(pToolTip);\r
+\r
+ HWND hToolTip = pToolTip? pToolTip->GetHwnd() : 0;\r
+ return (CToolTip*) FromHandle( (HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hToolTip, 0L) );\r
+ }\r
+\r
+ inline void CListView::SetWorkAreas( int nWorkAreas, CRect& pRectArray ) const\r
+ // Sets the working area within a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ ListView_SetWorkAreas( m_hWnd, nWorkAreas, pRectArray );\r
+ }\r
+\r
+ inline int CListView::SubItemHitTest( LVHITTESTINFO& htInfo ) const\r
+ // Determines which list-view item or subitem is located at a given position.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SubItemHitTest( m_hWnd, &htInfo );\r
+ }\r
+\r
+ // Operations\r
+\r
+ inline BOOL CListView::Arrange( UINT nCode ) const\r
+ // Arranges items in icon view.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_Arrange( m_hWnd, nCode );\r
+ }\r
+\r
+ inline HIMAGELIST CListView::CreateDragImage( int iItem, CPoint& pt ) const\r
+ // Creates a drag image list for the specified item.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_CreateDragImage( m_hWnd, iItem, &pt );\r
+ }\r
+\r
+ inline BOOL CListView::DeleteAllItems( ) const\r
+ // ListView_DeleteAllItems\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_DeleteAllItems( m_hWnd );\r
+ }\r
+\r
+ inline BOOL CListView::DeleteColumn( int iCol ) const\r
+ // Removes a column from a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_DeleteColumn( m_hWnd, iCol );\r
+ }\r
+\r
+ inline BOOL CListView::DeleteItem( int iItem ) const\r
+ // Removes an item from a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_DeleteItem( m_hWnd, iItem );\r
+ }\r
+\r
+ inline CEdit* CListView::EditLabel( int iItem ) const\r
+ // Begins in-place editing of the specified list-view item's text.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (CEdit*)FromHandle( ListView_EditLabel( m_hWnd, iItem ) );\r
+ }\r
+\r
+ inline BOOL CListView::EnsureVisible( int iItem, BOOL fPartialOK ) const\r
+ // Ensures that a list-view item is either entirely or partially visible,\r
+ // scrolling the list-view control if necessary.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(LVM_ENSUREVISIBLE, (WPARAM)iItem, (LPARAM)fPartialOK );\r
+ }\r
+\r
+ inline int CListView::FindItem( LVFINDINFO& FindInfo, int iStart /*= -1*/ ) const\r
+ // Searches for a list-view item with the specified characteristics.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_FindItem( m_hWnd, iStart, &FindInfo );\r
+ }\r
+\r
+ inline int CListView::HitTest( LVHITTESTINFO& HitTestInfo ) const\r
+ // Determines which list-view item, if any, is at a specified position.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_HitTest( m_hWnd, &HitTestInfo );\r
+ }\r
+\r
+ inline int CListView::HitTest( CPoint pt, UINT* pFlags /*= NULL*/ ) const\r
+ // Determines which list-view item, if any, is at a specified position.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVHITTESTINFO hti = {0};\r
+ hti.flags = *pFlags;\r
+ hti.pt = pt;\r
+ return ListView_HitTest( m_hWnd, &hti );\r
+ }\r
+\r
+ inline int CListView::InsertColumn( int iCol, const LVCOLUMN& Column ) const\r
+ // Inserts a new column in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_InsertColumn( m_hWnd, iCol, &Column );\r
+ }\r
+\r
+ inline int CListView::InsertColumn( int iCol, LPCTSTR pszColumnHeading, int iFormat /*= LVCFMT_LEFT*/,\r
+ int iWidth /*= -1*/, int iSubItem /*= -1*/ ) const\r
+ // Inserts a new column in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVCOLUMN lvc = {0};\r
+ lvc.mask = LVCF_TEXT|LVCF_ORDER|LVCF_FMT;\r
+ if (-1 != iWidth)\r
+ {\r
+ lvc.mask |= LVCF_WIDTH; \r
+ lvc.cx = iWidth; \r
+ }\r
+ if (-1 != iSubItem)\r
+ {\r
+ lvc.mask |= LVCF_SUBITEM; \r
+ lvc.iSubItem = iSubItem;\r
+ }\r
+\r
+ lvc.iOrder = iCol;\r
+ lvc.pszText = (LPTSTR)pszColumnHeading;\r
+ lvc.fmt = iFormat;\r
+ lvc.iSubItem = iSubItem;\r
+ return ListView_InsertColumn( m_hWnd, iCol, &lvc );\r
+ }\r
+\r
+ inline int CListView::InsertItem( const LVITEM& Item ) const\r
+ // Inserts a new item in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_InsertItem( m_hWnd, &Item );\r
+ }\r
+\r
+ inline int CListView::InsertItem( int iItem, LPCTSTR pszText ) const\r
+ // Inserts a new item in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.pszText = (LPTSTR)pszText;\r
+ lvi.mask = LVIF_TEXT;\r
+ return ListView_InsertItem( m_hWnd, &lvi );\r
+ }\r
+\r
+ inline int CListView::InsertItem( int iItem, LPCTSTR pszText, int iImage ) const\r
+ // Inserts a new item in a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ LVITEM lvi = {0};\r
+ lvi.iItem = iItem;\r
+ lvi.pszText = (LPTSTR)pszText;\r
+ lvi.iImage = iImage;\r
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE;\r
+ return ListView_InsertItem( m_hWnd, &lvi );\r
+ }\r
+\r
+ inline BOOL CListView::RedrawItems( int iFirst, int iLast ) const\r
+ // Forces a list-view control to redraw a range of items.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_RedrawItems( m_hWnd, iFirst, iLast );\r
+ }\r
+\r
+ inline BOOL CListView::Scroll( CSize sz ) const\r
+ // Scrolls the content of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_Scroll( m_hWnd, sz.cx, sz.cy );\r
+ }\r
+\r
+ inline BOOL CListView::SortItems( PFNLVCOMPARE pfnCompare, DWORD_PTR dwData ) const\r
+ // Uses an application-defined comparison function to sort the items of a list-view control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_SortItems( m_hWnd, pfnCompare, dwData );\r
+ }\r
+\r
+ inline BOOL CListView::Update( int iItem ) const\r
+ // Updates a list-view item. If the list-view control has the LVS_AUTOARRANGE style,\r
+ // the list-view control is rearranged.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return ListView_Update( m_hWnd, iItem );\r
+ }\r
+\r
+} // namespace Win32xx\r
+\r
+#endif // #ifndef _WIN32XX_LISTVIEW_H_\r
+\r