• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Windows/Control/ListView.h
2 
3 #ifndef __WINDOWS_CONTROL_LISTVIEW_H
4 #define __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(int columnIndex)31   bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); }
32 
InsertColumn(int columnIndex,const LVCOLUMN * columnInfo)33   int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); }
34   int InsertColumn(int columnIndex, LPCTSTR text, int width);
SetColumnOrderArray(int count,const int * columns)35   bool SetColumnOrderArray(int count, const int *columns) { return BOOLToBool(ListView_SetColumnOrderArray(_window, count, columns)); }
36 
37   /*
38   int GetNumColumns()
39   {
40     HWND header = ListView_GetHeader(_window);
41     if (!header)
42       return -1;
43     return Header_GetItemCount(header);
44   }
45   */
46 
InsertItem(const LVITEM * item)47   int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); }
48   int InsertItem(int index, LPCTSTR text);
SetItem(const LVITEM * item)49   bool SetItem(const LVITEM* item) { return BOOLToBool(ListView_SetItem(_window, item)); }
50   int SetSubItem(int index, int subIndex, LPCTSTR text);
51 
52   #ifndef _UNICODE
53 
InsertColumn(int columnIndex,const LVCOLUMNW * columnInfo)54   int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMsg(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); }
55   int InsertColumn(int columnIndex, LPCWSTR text, int width);
InsertItem(const LV_ITEMW * item)56   int InsertItem(const LV_ITEMW* item) { return (int)SendMsg(LVM_INSERTITEMW, 0, (LPARAM)item); }
57   int InsertItem(int index, LPCWSTR text);
SetItem(const LV_ITEMW * item)58   bool SetItem(const LV_ITEMW* item) { return BOOLToBool((BOOL)SendMsg(LVM_SETITEMW, 0, (LPARAM)item)); }
59   int SetSubItem(int index, int subIndex, LPCWSTR text);
60 
61   #endif
62 
DeleteItem(int itemIndex)63   bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); }
64 
GetSelectedCount()65   UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); }
GetItemCount()66   int GetItemCount() const { return ListView_GetItemCount(_window); }
67 
GetSelectionMark()68   INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); }
69 
SetItemCount(int numItems)70   void SetItemCount(int numItems) { ListView_SetItemCount(_window, numItems); }
SetItemCountEx(int numItems,DWORD flags)71   void SetItemCountEx(int numItems, DWORD flags) {  ListView_SetItemCountEx(_window, numItems, flags); }
72 
GetNextItem(int startIndex,UINT flags)73   int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); }
GetNextSelectedItem(int startIndex)74   int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); }
GetFocusedItem()75   int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); }
76 
GetItem(LVITEM * item)77   bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); }
78   bool GetItemParam(int itemIndex, LPARAM &param) const;
GetItemText(int itemIndex,int subItemIndex,LPTSTR text,int textSizeMax)79   void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const
80     { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); }
SortItems(PFNLVCOMPARE compareFunction,LPARAM dataParam)81   bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam)
82     { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); }
83 
SetItemState(int index,UINT state,UINT mask)84   void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); }
SetItemState_Selected(int index,bool select)85   void SetItemState_Selected(int index, bool select) { SetItemState(index, select ? LVIS_SELECTED : 0, LVIS_SELECTED); }
SetItemState_Selected(int index)86   void SetItemState_Selected(int index) { SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); }
SelectAll()87   void SelectAll() { SetItemState_Selected(-1); }
SetItemState_FocusedSelected(int index)88   void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); }
GetItemState(int index,UINT mask)89   UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); }
IsItemSelected(int index)90   bool IsItemSelected(int index) const { return GetItemState(index, LVIS_SELECTED) == LVIS_SELECTED; }
91 
GetColumn(int columnIndex,LVCOLUMN * columnInfo)92   bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const
93     { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); }
94 
SetImageList(HIMAGELIST imageList,int imageListType)95   HIMAGELIST SetImageList(HIMAGELIST imageList, int imageListType)
96     { return ListView_SetImageList(_window, imageList, imageListType); }
97 
98   // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3)
GetExtendedListViewStyle()99   DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); }
SetExtendedListViewStyle(DWORD exStyle)100   void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); }
SetExtendedListViewStyle(DWORD exMask,DWORD exStyle)101   void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); }
102 
SetCheckState(UINT index,bool checkState)103   void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); }
GetCheckState(UINT index)104   bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); }
105 
EnsureVisible(int index,bool partialOK)106   bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); }
107 
GetItemRect(int index,RECT * rect,int code)108   bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); }
109 
GetEditControl()110   HWND GetEditControl() { return ListView_GetEditControl(_window) ; }
EditLabel(int itemIndex)111   HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; }
112 
RedrawItems(int firstIndex,int lastIndex)113   bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); }
RedrawAllItems()114   bool RedrawAllItems()
115   {
116     if (GetItemCount() > 0)
117       return RedrawItems(0, GetItemCount() - 1);
118     return true;
119   }
RedrawItem(int index)120   bool RedrawItem(int index) { return RedrawItems(index, index); }
121 
HitTest(LPLVHITTESTINFO info)122   int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); }
GetBkColor()123   COLORREF GetBkColor() { return ListView_GetBkColor(_window); }
SetColumnWidth(int iCol,int cx)124   bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); }
SetColumnWidthAuto(int iCol)125   bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); }
126 };
127 
128 class CListView2: public CListView
129 {
130   WNDPROC _origWindowProc;
131 public:
132   void SetWindowProc();
133   virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
134 };
135 
136 /*
137 class CListView3: public CListView2
138 {
139 public:
140   virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
141 };
142 */
143 
144 }}
145 
146 #endif
147