TVN_SELCHANGING not received

China☆狼群 提交于 2019-12-24 15:36:23

问题


I have a WTL81 app. CMainFrame has a child CPaneContainer, that has a child window CTreeViewCtrl. The problem is CTreeViewCtrl doesn't receive TVN_SELCHANGING message.

I have "spied" CTreeViewCtrl and his parent (CPaneContainer) and no notification code is received.

CMainFrame is implemented from public CFrameWindowImpl<CMainFrame>

CPaneContainer is implemented like this

class PaneContainerReflectNotif : public CPaneContainer 
{
    BEGIN_MSG_MAP(PaneContainerReflectNotif)
        CHAIN_MSG_MAP(CPaneContainer)
        REFLECT_NOTIFICATIONS()
    END_MSG_MAP()
};

Tree is implemented like this

class MyTreeView : 
    public CWindowImpl<CatalogTreeView, CTreeViewCtrl>,
    public CCustomDraw<CatalogTreeView>,
    public CTheme

   ...

BEGIN_MSG_MAP_EX(MyTreeView )
    MSG_WM_CREATE(OnCreate)
    MSG_WM_DESTROY(OnDestroy)
    REFLECTED_NOTIFY_CODE_HANDLER_EX(NM_DBLCLK, OnDblClick)
    REFLECTED_NOTIFY_CODE_HANDLER_EX(TVN_ITEMEXPANDING, OnItemExpanding)
    REFLECTED_NOTIFY_CODE_HANDLER_EX(TVN_SELCHANGING, OnSelChanged)

OnDblClick - works fine
OnItemExpanding - works fine
OnSelChanged - doesn't work

any ideas on what could be the problem ?


回答1:


Solved. My problem was that treeview was multi-selct and that kind of tree doesn't send TVN_SELCHANGING notifications




回答2:


You have not mentioned why do you need TVN_SELCHANGING. The event gets fired when the tree nodes are getting changed, and another tree node is being selected.

As an alternative, you might try TVN_SELCHANGED or HitTest( ). I am providing a MFC link .. http://msdn.microsoft.com/en-us/library/x0w7ft34.aspx



来源:https://stackoverflow.com/questions/5613536/tvn-selchanging-not-received

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!