Skip to content

Instantly share code, notes, and snippets.

@kevinw
Created August 26, 2008 16:28
Show Gist options
  • Save kevinw/7290 to your computer and use it in GitHub Desktop.
Save kevinw/7290 to your computer and use it in GitHub Desktop.
bool wxTopLevelWindowMSW::Show(bool show)
{
// don't use wxWindow version as we want to call DoShowWindow() ourselves
if ( !wxWindowBase::Show(show) )
return false;
int nShowCmd;
if ( show )
{
if ( m_maximizeOnShow )
{
// show and maximize
nShowCmd = SW_MAXIMIZE;
// This is necessary, or no window appears
#if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
DoShowWindow(SW_SHOW);
#endif
m_maximizeOnShow = false;
}
else // just show
{
// we shouldn't use SW_SHOW which also activates the window for
// tool frames (as they shouldn't steal focus from the main window)
// nor for the currently disabled windows as they would be enabled
// as a side effect
if ( HasFlag(wxFRAME_TOOL_WINDOW) || !IsEnabled() )
nShowCmd = SW_SHOWNA;
else
nShowCmd = SW_SHOW;
}
}
else // hide
{
nShowCmd = SW_HIDE;
}
DoShowWindow(nShowCmd);
#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
// Addornments have to be added when the frame is the correct size
wxFrame* frame = wxDynamicCast(this, wxFrame);
if (frame && frame->GetMenuBar())
frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
#endif
// we only set pending size if we're maximized before being shown, now that
// we're shown we don't need it any more (it is reset in size event handler
// for child windows but we have to do it ourselves for this parent window)
m_pendingSize = wxDefaultSize;
return true;
}
bool wxTopLevelWindowMSW::ShowNoActivate(bool show)
{
// don't use wxWindow version as we want to call DoShowWindow() ourselves
if ( !wxWindowBase::Show(show) )
return false;
int nShowCmd;
if ( show )
{
if ( m_maximizeOnShow )
{
// show and maximize
nShowCmd = SW_MAXIMIZE;
// This is necessary, or no window appears
#if defined( __WINCE_STANDARDSDK__) || defined(__SMARTPHONE__)
DoShowWindow(SW_SHOW);
#endif
m_maximizeOnShow = false;
}
else // just show
{
nShowCmd = SW_SHOWNA;
}
}
else // hide
{
nShowCmd = SW_HIDE;
}
DoShowWindow(nShowCmd);
#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
// Addornments have to be added when the frame is the correct size
wxFrame* frame = wxDynamicCast(this, wxFrame);
if (frame && frame->GetMenuBar())
frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
#endif
// we only set pending size if we're maximized before being shown, now that
// we're shown we don't need it any more (it is reset in size event handler
// for child windows but we have to do it ourselves for this parent window)
m_pendingSize = wxDefaultSize;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment