• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Windows/Control/ListView.h
2 
3 #ifndef ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
4 #define ZIP7_INC_WINDOWS_CONTROL_LISTVIEW_H
5 
6 #include "../../Common/MyWindows.h"
7 
8 #include <CommCtrl.h>
9 
10 #include "../Window.h"
11 
12 namespace NWindows {
13 namespace NControl {
14 
15 class CListView: public NWindows::CWindow
16 {
17 public:
18   bool CreateEx(DWORD exStyle, DWORD style,
19       int x, int y, int width, int height,
20       HWND parentWindow, HMENU idOrHMenu,
21       HINSTANCE instance, LPVOID createParam);
22 
SetUnicodeFormat()23   void SetUnicodeFormat()
24   {
25     #ifndef UNDER_CE
26     ListView_SetUnicodeFormat(_window, TRUE);
27     #endif
28   }
29 
DeleteAllItems()30   bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); }
DeleteColumn(unsigned columnIndex)31   bool DeleteColumn(unsigned columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
32 
InsertColumn(unsigned columnIndex,const LVCOLUMN * columnInfo)33   int InsertColumn(unsigned columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
34   int InsertColumn(unsigned columnIndex, LPCTSTR text, int width);
SetColumnOrderArray(unsigned count,const int * columns)35   bool SetColumnOrderArray(unsigned count, const int *columns)
36     { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, (int *)(void *)columns)); }
37 
38   /*
39   int GetNumColumns()
40   {
41     HWND header = ListView_GetHeader(_window);
42     if (!header)
43       return -1;
44     return Header_GetItemCount(header);
45   }
46   */
47 
InsertItem(const LVITEM * item)48   int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
49   int InsertItem(unsigned index, LPCTSTR text);
SetItem(const LVITEM * item)50   bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
51   int SetSubItem(unsigned index, unsigned subIndex, LPCTSTR text);
52 
53   #ifndef _UNICODE
54 
InsertColumn(unsigned columnIndex,const LVCOLUMNW * columnInfo)55   int InsertColumn(unsigned columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
56   int InsertColumn(unsigned columnIndex, LPCWSTR text, int width);
InsertItem(const LV_ITEMW * item)57   int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
58   int InsertItem(unsigned index, LPCWSTR text);
SetItem(const LV_ITEMW * item)59   bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
60   int SetSubItem(unsigned index, unsigned subIndex, LPCWSTR text);
61 
62   #endif
63 
DeleteItem(unsigned itemIndex)64   bool DeleteItem(unsigned itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
65 
GetSelectedCount()66   UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
GetItemCount()67   int GetItemCount() const { return ListView_GetItemCount(_window); }
68 
GetSelectionMark()69   INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
70 
SetItemCount(unsigned numItems)71   void SetItemCount(unsigned numItems) { ListView_SetItemCount(_window, numItems); }
SetItemCountEx(unsigned numItems,DWORD flags)72   void SetItemCountEx(unsigned numItems, DWORD flags) {  ListView_SetItemCountEx(_window, numItems, flags); }
73 
74   /* startIndex : The index of the item with which to begin the search,
75      or -1 to find the first item that matches the specified flags.
76      The specified item itself is excluded from the search. */
GetNextItem(int startIndex,UINT flags)77   int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
GetNextSelectedItem(int startIndex)78   int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
GetFocusedItem()79   int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
80 
GetItem(LVITEM * item)81   bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
82   bool GetItemParam(unsigned itemIndex, LPARAM &param) const;
83   /*
84   void GetItemText(unsigned itemIndex, unsigned subItemIndex, LPTSTR text, unsigned textSizeMax) const
85     { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax) }
86   */
SortItems(PFNLVCOMPARE compareFunction,LPARAM dataParam)87   bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
88     { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
89 
90   // If (index == -1), then the state change is applied to all items.
SetItemState(int index,UINT state,UINT mask)91   void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask) }
SetItemState_Selected(int index,bool select)92   void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
SetItemState_Selected(int index)93   void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
SelectAll()94   void SelectAll() { SetItemState_Selected(-1); }
SetItemState_FocusedSelected(int index)95   void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
GetItemState(int index,UINT mask)96   UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
IsItemSelected(int index)97   bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
98 
GetColumn(unsigned columnIndex,LVCOLUMN * columnInfo)99   bool GetColumn(unsigned columnIndex, LVCOLUMN* columnInfo) const
100     { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
101 
SetImageList(HIMAGELIST imageList,int imageListType)102   HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
103     { return ListView_SetImageList(_window, imageList, imageListType); }
104 
105   // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
GetExtendedListViewStyle()106   DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); }
SetExtendedListViewStyle(DWORD exStyle)107   void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
SetExtendedListViewStyle(DWORD exMask,DWORD exStyle)108   void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
109 
SetCheckState(UINT index,bool checkState)110   void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)) }
GetCheckState(UINT index)111   bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
112 
EnsureVisible(int index,bool partialOK)113   bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
114 
GetItemRect(int index,RECT * rect,int code)115   bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
116 
GetEditControl()117   HWND GetEditControl() { return ListView_GetEditControl(_window) ; }
EditLabel(int itemIndex)118   HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; }
119 
RedrawItems(int firstIndex,int lastIndex)120   bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
RedrawAllItems()121   bool RedrawAllItems()
122   {
123     if (GetItemCount() > 0)
124       return RedrawItems(0, GetItemCount() - 1);
125     return true;
126   }
RedrawItem(int index)127   bool RedrawItem(int index) { return RedrawItems(index, index); }
128 
HitTest(LPLVHITTESTINFO info)129   int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
GetBkColor()130   COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
SetColumnWidth(int iCol,int cx)131   bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
SetColumnWidthAuto(int iCol)132   bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
133 };
134 
135 class CListView2: public CListView
136 {
137   WNDPROC _origWindowProc;
138   // ~CListView2() ZIP7_eq_delete;
139 public:
~CListView2()140   virtual ~CListView2() {}
CListView2()141   CListView2() {}
142   void SetWindowProc();
143   virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
144 };
145 
146 /*
147 class CListView3: public CListView2
148 {
149 public:
150   virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
151 };
152 */
153 
154 }}
155 
156 #endif
157