Code: Select all
MyFrame::MyFrame()
{
wxNotebook* sometabs = new wxNotebook();
}
//...
this->Show(false);//hide form
//...
sometabs->AddPage(/*...*/);//addpage. what going on:
wxNotebook::SetSelection(selNew) -> (invoke by event) ->
wxNotebook::OnSelChange(wxNotebookEvent& event)
Code: Select all
void wxNotebook::OnSelChange(wxNotebookEvent& event)
{
// is it our tab control?
if ( event.GetEventObject() == this )
{
int sel = event.GetOldSelection();
if ( sel != -1 )
m_pages[sel]->Show(false);
sel = event.GetSelection();
if ( sel != -1 )
{
wxNotebookPage *pPage = m_pages[sel];
pPage->Show(true);
// As per bug report:
// http://sourceforge.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863,
// we should not set the page focus (and thereby the focus for
// a child window) since it erroneously selects radio button controls and also
// breaks keyboard handling for a notebook's scroll buttons. So
// we always focus the notebook and not the page.
SetFocus();
}
else // no pages in the notebook, give the focus to itself
{
SetFocus();
}
m_nSelection = sel;
}
// we want to give others a chance to process this message as well
event.Skip();
}
as the result of SetFocus() is, that current window (even of another application) lost focus, and focus come to hidden form.