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
This commit is contained in:
Vadim Zeitlin
2010-10-24 22:41:08 +00:00
parent 1da2783c33
commit 942f40ca24

View File

@@ -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;