MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / OnColumnClick

Method OnColumnClick

WinArk/VirtualListView.h:213–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211 }
212
213 LRESULT OnColumnClick(int /*idCtrl*/, LPNMHDR hdr, BOOL& /*bHandled*/) {
214 auto lv = (NMLISTVIEW*)hdr;
215 // auto col = lv->iSubItem;
216 auto col = GetRealColumn(hdr->hwndFrom, lv->iSubItem);
217
218 auto p = static_cast<T*>(this);
219 if (!p->IsSortable(hdr->hwndFrom,col))
220 return 0;
221
222 auto si = FindById(hdr->idFrom);
223 if (si == nullptr) {
224 SortInfo s;
225 s.hWnd = hdr->hwndFrom;
226 s.Id = hdr->idFrom;
227 m_Controls.push_back(s);
228 si = m_Controls.data() + m_Controls.size() - 1;
229 }
230
231 auto oldSortColumn = si->SortColumn;
232 if (col == si->SortColumn)
233 si->SortAscending = !si->SortAscending;
234 else {
235 si->SortColumn = col;
236 si->SortAscending = true;
237 }
238
239 HDITEM h;
240 h.mask = HDI_FORMAT;
241 CListViewCtrl list(hdr->hwndFrom);
242 auto header = list.GetHeader();
243 header.GetItem(si->SortColumn, &h);
244 h.fmt = (h.fmt & HDF_JUSTIFYMASK) | HDF_STRING | (si->SortAscending ? HDF_SORTUP : HDF_SORTDOWN);
245 header.SetItem(si->SortColumn, &h);
246
247 if (oldSortColumn >= 0 && oldSortColumn != si->SortColumn) {
248 h.mask = HDI_FORMAT;
249 header.GetItem(oldSortColumn, &h);
250 h.fmt = (h.fmt & HDF_JUSTIFYMASK) | HDF_STRING;
251 header.SetItem(oldSortColumn, &h);
252 }
253
254 static_cast<T*>(this)->DoSort(si);
255 list.RedrawItems(list.GetTopIndex(), list.GetTopIndex() + list.GetCountPerPage());
256
257 return 0;
258 }
259
260 LRESULT OnFindItem(int /*idCtrl*/, LPNMHDR hdr, BOOL& /*bHandled*/) {
261 auto fi = (NMLVFINDITEM*)hdr;

Callers

nothing calls this directly

Calls 4

push_backMethod · 0.80
IsSortableMethod · 0.45
sizeMethod · 0.45
DoSortMethod · 0.45

Tested by

no test coverage detected