? Problem With Message Reflection (Sorting List Control)
Hi,
I am trying to create a customized CListCtrl that can do its own sorting of
primitive types by using message reflection. This way, it can do sorting without
extra work for integers, strings, etc., but can be overridden by the dialog to
sort fancier types.
However it does not seem to be working. I've set a breakpoint in both the
control's and dialog's OnLvnColumnclick functions. I then test to see which one
is hit when the header is clicked. I've tried various combinations with one or
the other message map entry in the control commented out, and even the whole
functions (and their declarations) commented out.
I'm not sure exactly how to get this done. The few sample sources I've managed
to find were not all consistent and some that looked like they should have
worked, did not.
How exactly can I do this? (For example, which on_notify. entry do I use in the
control? one? the other? both?) I've included the main parts of what I've got
below.
(Also, I may as well allow for runtime decision of whose click-handler to use,
and I'm guessing that is accomplished by having the dialog handle the header
click and have it call the control's handler, right?)
Thanks.
--
Alec S.
news/alec->synetech/cjb/net
class CTestDlg : public CDialog {
afx_msg void OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
ON_NOTIFY (LVN_COLUMNCLICK, IDC_LIST, OnLvnColumnclick)
END_MESSAGE_MAP()
void CTestDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
.
*pResult = 0;
}
class CCustList : public CListCtrl {
afx_msg void OnLvnColumnclick (NMHDR *pNMHDR, LRESULT *pResult);
}
BEGIN_MESSAGE_MAP (CCustList, CListCtrl)
ON_NOTIFY (LVN_COLUMNCLICK, 0, OnLvnColumnclick)
ON_NOTIFY_REFLECT (LVN_COLUMNCLICK, OnLvnColumnclick)
}
void CCustList::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
.
*pResult = 0;
}