如何检测 CListCtrl 选择更改?
当用户在 CListCtrl 中选择一行时,我想执行一些代码(报表视图,我不关心其他查看模式).
I want to execute some code when the user selects a row in a CListCtrl (report view, I don't care about the other viewing modes).
我如何捕捉这个事件?是否有一些我可以映射的消息或类似OnSelectionChanged"之类的方法?
How do I catch this event? is there some message I can map or a method like "OnSelectionChanged" or something like that?
推荐答案
也试试:
BEGIN_MESSAGE_MAP(cDlgRun, CDialog)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
END_MESSAGE_MAP()
/* ... */
void cDlgRun::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if ((pNMListView->uChanged & LVIF_STATE)
&& (pNMListView->uNewState & LVIS_SELECTED))
{
// do stuff...
}
}
相关文章