8 unsigned insert_item(HWND p_listview,
unsigned p_index,
const char * p_name,LPARAM p_param)
10 if (p_index == ~0) p_index = ListView_GetItemCount(p_listview);
15 item.mask = LVIF_TEXT | LVIF_PARAM;
17 item.lParam = p_param;
18 item.pszText =
const_cast<TCHAR*
>(os_string_temp.
get_ptr());
20 LRESULT ret = uSendMessage(p_listview,LVM_INSERTITEM,0,(LPARAM)&item);
21 if (ret < 0)
return ~0;
22 else return (
unsigned) ret;
25 unsigned insert_item2(HWND p_listview,
unsigned p_index,
const char * col0,
const char * col1, LPARAM p_param) {
26 unsigned i =
insert_item( p_listview, p_index, col0, p_param );
33 unsigned insert_item3(HWND p_listview,
unsigned p_index,
const char * col0,
const char * col1,
const char * col2, LPARAM p_param) {
34 unsigned i =
insert_item( p_listview, p_index, col0, p_param );
42 unsigned insert_column(HWND p_listview,
unsigned p_index,
const char * p_name,
unsigned p_width_dlu)
46 RECT rect = {0,0,p_width_dlu,0};
47 MapDialogRect(GetParent(p_listview),&rect);
50 data.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT;
51 data.fmt = LVCFMT_LEFT;
53 data.pszText =
const_cast<TCHAR*
>(os_string_temp.
get_ptr());
55 LRESULT ret = uSendMessage(p_listview,LVM_INSERTCOLUMN,p_index,(LPARAM)&data);
56 if (ret < 0)
return ~0;
57 else return (
unsigned) ret;
61 enum {buffer_length = 1024*64};
63 ListView_GetItemText(p_listview,p_index,p_column,buffer.
get_ptr(),buffer_length);
67 bool set_item_text(HWND p_listview,
unsigned p_index,
unsigned p_column,
const char * p_name)
73 item.mask = LVIF_TEXT;
75 item.iSubItem = p_column;
76 item.pszText =
const_cast<TCHAR*
>(os_string_temp.
get_ptr());
77 return uSendMessage(p_listview,LVM_SETITEM,0,(LPARAM)&item) ?
true :
false;
83 item.mask = LVIF_STATE;
85 item.stateMask = LVIS_SELECTED;
86 if (!uSendMessage(p_listview,LVM_GETITEM,0,(LPARAM)&item))
return false;
87 return (item.state & LVIS_SELECTED) ?
true :
false;
92 PFC_ASSERT( ::IsWindow(p_listview) );
94 item.stateMask = LVIS_SELECTED;
95 item.state = p_state ? LVIS_SELECTED : 0;
96 WIN32_OP_D( SendMessage(p_listview,LVM_SETITEMSTATE,(WPARAM)p_index,(LPARAM)&item) );
101 LRESULT temp = SendMessage(p_listview,LVM_GETITEMCOUNT,0,0);
102 if (temp < 0)
return false;
103 ListView_SetSelectionMark(p_listview,p_index);
104 unsigned n;
const unsigned m = pfc::downcast_guarded<unsigned>(temp);
106 enum {mask = LVIS_FOCUSED | LVIS_SELECTED};
107 ListView_SetItemState(p_listview,n,n == p_index ? mask : 0, mask);
114 return uSendMessage(p_listview,LVM_ENSUREVISIBLE,p_index,FALSE) ?
true :
false;
120 POINT pt = {(short)LOWORD(p_coords),(short)HIWORD(p_coords)};
125 if (p_coords.x == -1 && p_coords.y == -1) {
128 ListView_EnsureVisible(p_list, firstsel, FALSE);
130 WIN32_OP_D( ListView_GetItemRect(p_list,firstsel,&rect,LVIR_BOUNDS) );
131 p_point.x = (rect.left + rect.right) / 2;
132 p_point.y = (rect.top + rect.bottom) / 2;
133 WIN32_OP_D( ClientToScreen(p_list,&p_point) );
136 WIN32_OP_D(GetClientRect(p_list,&rect));
137 p_point.x = (rect.left + rect.right) / 2;
138 p_point.y = (rect.top + rect.bottom) / 2;
139 WIN32_OP_D(ClientToScreen(p_list,&p_point));
141 p_selection = firstsel;
146 WIN32_OP_D( ScreenToClient(p_list,&client) );
147 LVHITTESTINFO
info = {};
149 p_selection = ListView_HitTest(p_list,&info);
155 LVCOLUMN col = {LVCF_ORDER};
156 return !! ListView_GetColumn(view, index, &col);
165 PFC_ASSERT(!
"Shouldn't get here!");
172 PFC_ASSERT( lo < hi );
173 const int mid = lo + (hi - lo) / 2;
174 PFC_ASSERT( lo < mid && mid < hi );
185 HWND header = ListView_GetHeader(listView);
186 PFC_ASSERT(header != NULL);
187 return Header_GetItemCount(header);
unsigned insert_item2(HWND p_listview, unsigned p_index, const char *col0, const char *col1, LPARAM p_param)
const t_item * get_ptr() const
unsigned insert_item3(HWND p_listview, unsigned p_index, const char *col0, const char *col1, const char *col2, LPARAM p_param)
bool set_item_text(HWND p_listview, unsigned p_index, unsigned p_column, const char *p_name)
unsigned insert_item(HWND p_listview, unsigned p_index, const char *p_name, LPARAM p_param)
void info(const char *p_message)
bool ensure_visible(HWND p_listview, unsigned p_index)
unsigned insert_column(HWND p_listview, unsigned p_index, const char *p_name, unsigned p_width_dlu)
void get_item_text(HWND p_listview, unsigned p_index, unsigned p_column, pfc::string_base &p_out)
string_utf8_from_wide string_utf8_from_os
int ListView_GetColumnCount(HWND listView)
void set_size(t_size p_size)
const wchar_t * get_ptr() const
bool is_item_selected(HWND p_listview, unsigned p_index)
static int ListView_GetFirstSelection(HWND p_listview)
void set_item_selection(HWND p_listview, unsigned p_index, bool p_state)
void ListView_GetContextMenuPoint(HWND p_list, LPARAM p_coords, POINT &p_point, int &p_selection)
bool select_single_item(HWND p_listview, unsigned p_index)
static bool ProbeColumn(HWND view, int index)