未收到 TVN_SELCHANGING
我有一个 WTL81 应用程序。 CMainFrame 有一个子 CPaneContainer,它有一个子窗口 CTreeViewCtrl。问题是 CTreeViewCtrl 没有收到 TVN_SELCHANGING 消息。
我“监视”了 CTreeViewCtrl 和他的父级 (CPaneContainer),但没有收到通知代码。
CMainFrame 是从公共 CFrameWindowImpl
实现的
CPaneContainer 是这样实现的,
class PaneContainerReflectNotif : public CPaneContainer
{
BEGIN_MSG_MAP(PaneContainerReflectNotif)
CHAIN_MSG_MAP(CPaneContainer)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
};
树是这样实现的
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 - 工作正常
OnItemExpanding - 工作正常
OnSelChanged - 不起作用
对于可能出现的问题有什么想法吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了。我的问题是树视图是多选的,并且这种树不会发送 TVN_SELCHANGING 通知
Solved. My problem was that treeview was multi-selct and that kind of tree doesn't send TVN_SELCHANGING notifications
您没有提到为什么需要 TVN_SELCHANGING。当树节点发生更改并且选择另一个树节点时,会触发该事件。
作为替代方案,您可以尝试 TVN_SELCHANGED 或 HitTest( )。我提供了一个 MFC 链接.. http://msdn.microsoft.com/en -us/library/x0w7ft34.aspx
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