Search code examples
mfcclistctrl

CListCtrl: Get DblClick on HeaderControl


Okay, it's been I while I wrote something in MFC, so please be patient with me. I have a class "CMyListCtrl" derived from CListCtrl and just want to know if a column-header has been double-clicked (left) on the header.

So I added to my MESSAGE_MAP:

ON_NOTIFY(HDN_ITEMDBLCLICK, 0, OnDblClickHeader)

and a function to CMyListCltr:

void CMyListCtrl::OnDblClickHeader(NMHDR* pNMHDR, LRESULT* pResult)
{
    HD_NOTIFY *phdn = (HD_NOTIFY *)pNMHDR;
    // TODO: Add your control notification handler code here
    *pResult = 0;
}

But: OnDblClickHeader is never called. I tried:

ON_NOTIFY
ON_NOTIFY_EX
ON_NOTIFY_RANGE (0-0xffff)
ON_NOTIFY_REFLECT
ON_NOTIFY_REFLECT_EX

... but: OnDblClickHeader is never called.

What might be wrong? Does the header has to get a special style?


Solution

  • According to the documentation you have to make sure that your control follows the statement that:
    Only header controls that are set to the HDS_BUTTONS style send this notification code.