简体   繁体   中英

MFC TVN_ITEMEXPANDING doesn't call the handler function

I have a CTreeCtrl and I like to use its TVN_ITEMEXPANDING message, but the handler function never calls.

CsetkliensDlg.h

afx_msg void OnItemExpanding(NMHDR* pNmhdr,LRESULT *lResult);

CsetkliensDlg.cpp

BEGIN_MESSAGE_MAP(CCsetkliensDlg, CDialogEx)
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, &CCsetkliensDlg::OnItemExpanding)
END_MESSAGE_MAP()

...

void CCsetkliensDlg::OnItemExpanding(NMHDR* pNmhdr,LRESULT *lResult)
{
    AfxMessageBox("almafa");
}

The items have childs.

You are trying to catch a notification in the parent dialog so you should use ON_NOTIFY instead of ON_NOTIFY_REFLECT.

Of course then your message map will be something lik:

ON_NOTIFY( TVN_ITEMEXPANDING, CTREECTRL_RESOURCES_ID, ONHandlerFunction)

You can use the reflection mechanism but then the handler should be in a CTreeCtrl derived class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM