Reputation: 1585
I have a CListCtrl in a CDialog. And most of the events are not getting called for CListCtrl. For example OnMouseMove is no getting called when my mouse pointer is on CListCtrl but works if mouse pointer is on window or editcontrol etc.
Note: my CListCtrl is set Report view.
Can anyone explain this behavior?
Upvotes: 0
Views: 358
Reputation: 56
I have just suffered similar symptoms, (reported in question "MFC CListCtrl does not appear after minimise-restore" under my name). I found exactly as you did, that many messages do not appear where you think they should, some not at all. And others have found the same thing. I solved that by creating my own class inheriting from CListCtrl and just overriding OnNotify(...). I then found I received the messages, trapped only the ones I wanted and revised the behaviour to suit in my own class. (I was simply preventing resizing of column widths.) No other code was needed in my case.
BOOL CCompilationListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
{
if(pHDN->hdr.code == HDN_BEGINTRACKW || pHDN->hdr.code == HDN_BEGINTRACKA)
{
*pResult = TRUE;
return TRUE;
}
if(pHDN->hdr.code == HDN_ENDTRACKW || pHDN->hdr.code == HDN_ENDTRACKA)
{
*pResult = TRUE;
return TRUE;
}
if(pHDN->hdr.code == HDN_DIVIDERDBLCLICKW || pHDN->hdr.code == HDN_DIVIDERDBLCLICKA)
{
*pResult = TRUE;
return TRUE;
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
Upvotes: 2