- wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId);
- event.SetEventObject(this);
- event.SetSelection(pagePos);
- event.SetOldSelection(m_selection);
+ if (flags & SetSelection_SendEvent)
+ {
+ event.SetEventObject(this);
+ event.SetSelection(pagePos);
+ event.SetOldSelection(m_selection);
+
+ // don't send the event if the old and new pages are the same; do send it
+ // otherwise and be prepared for it to be vetoed
+ allowed = (int)pagePos == m_selection ||
+ !GetEventHandler()->ProcessEvent(event) ||
+ event.IsAllowed();
+ }