From 942f40ca244156ea004d579be735d60cda1bef9d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Oct 2010 22:41:08 +0000 Subject: [PATCH] Avoid duplicate wxEVT_COMMAND_TREE_SEL_CHANG{ING,ED} events in wxMSW. When changing the selected item programmatically 2 CHANGING and CHANGED events were sent because the assumption that comctl32.dll didn't send these events itself was not correct any more, it does send them at least since XP. However to avoid the tests for its exact version it's simpler to just ignore the events it generates and continue sending our own ones. Closes #11274. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65906 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 9f1f4a7142..6cb53d2876 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1966,10 +1966,10 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select) // leave itemNew invalid } - // in spite of the docs (MSDN Jan 99 edition), we don't seem to receive - // the notification from the control (i.e. TVN_SELCHANG{ED|ING}), so - // send them ourselves - + // Recent versions of comctl32.dll send TVN_SELCHANG{ED,ING} events + // when we call TreeView_SelectItem() but apparently some old ones did + // not so send the events ourselves and ignore those generated by + // TreeView_SelectItem() if m_changingSelection is set. wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING, this, itemNew); changingEvent.SetOldItem(itemOld); @@ -3474,7 +3474,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // we have to handle both messages: case TVN_SELCHANGEDA: case TVN_SELCHANGEDW: - if ( !HasFlag(wxTR_MULTIPLE) || !m_changingSelection ) + if ( !m_changingSelection ) { eventType = wxEVT_COMMAND_TREE_SEL_CHANGED; } @@ -3482,7 +3482,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_SELCHANGINGA: case TVN_SELCHANGINGW: - if ( !HasFlag(wxTR_MULTIPLE) || !m_changingSelection ) + if ( !m_changingSelection ) { if ( eventType == wxEVT_NULL ) eventType = wxEVT_COMMAND_TREE_SEL_CHANGING; -- 2.45.2