From 426ebc992b1f8e85798292e858e90a94d8e2a158 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Nov 2010 01:22:25 +0000 Subject: [PATCH] Send page changed event after changing the page in wxMSW wxNotebook. Update the currently selected page before generating wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event in wxMSW wxNotebook. This is more consistent with other ports and more logical as "-ED" events are supposed to be sent after the action they notify about is completed. And it also allows to set the focus in this event handler whereas any attempts to do it would have been disregarded before as changing the active page resets focus. Notice that this does introduce an incompatibility: calling wxNotebook::GetSelection() from PAGE_CHANGED event handler now returns the new page and not the old one as before. Again, this is more logical and more consistent. Closes #12688. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66224 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 6 ++++++ src/msw/notebook.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index d125bb1f5d..dac31aa9f4 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -169,6 +169,12 @@ Changes in behaviour not resulting in compilation errors, please read this! regardless of whether the flag was specified or not. This only affects legacy ANSI builds. +- wxNotebook::GetSelection() returns the new page index when called from + wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event handler in wxMSW, not the old one. + The new behaviour is consistent with wxGTK and more logical but different + from the previous versions. Using wxNotebookEvent::GetSelection() instead of + querying the notebook selection avoids the problem and is recommended. + Changes in behaviour which may result in compilation errors ----------------------------------------------------------- diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 05a1136e4a..4b3c6e0aee 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -454,11 +454,13 @@ int wxNotebook::SetSelection(size_t nPage) if ( SendPageChangingEvent(nPage) ) { // program allows the page change - SendPageChangedEvent(m_selection, nPage); + const int selectionOld = m_selection; UpdateSelection(nPage); TabCtrl_SetCurSel(GetHwnd(), nPage); + + SendPageChangedEvent(selectionOld, nPage); } } -- 2.45.2