部分代码示例如下:
BOOL ClickListColumn(CListCtrl& listCtrl, int index)
{
if(index >= listCtrl.GetHeaderCtrl()->GetItemCount())
return FALSE;
NM_LISTVIEW nmListView;
memset(&nmListView, 0, sizeof(nmListView));
nmListView.iItem = -1;//NOT USED IN HERE
nmListView.iSubItem = index;//INDEX VALUE
nmListView.hdr.hwndFrom = listCtrl.GetSafeHwnd();
nmListView.hdr.idFrom = listCtrl.GetDlgCtrlID();
nmListView.hdr.code = LVN_COLUMNCLICK;
return SendMessage(WM_NOTIFY, listCtrl.GetDlgCtrlID(), (LPARAM)&nmListView);
}