X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a6c2e2c7657b09cfbccb82c966451cc902802893..19253261f5c6127f5448078295d4cbe1521d469f:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index fae5b35149..d0e47ea963 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -221,9 +221,11 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const } #ifndef __WXWINCE__ - if ( style & wxSYSTEM_MENU ) + // notice that if wxCLOSE_BOX is specified we need to use WS_SYSMENU too as + // otherwise the close box doesn't appear + if ( style & (wxSYSTEM_MENU | wxCLOSE_BOX) ) msflags |= WS_SYSMENU; -#endif +#endif // !__WXWINCE__ // NB: under CE these 2 styles are not supported currently, we should // call Minimize()/Maximize() "manually" if we want to support them @@ -423,25 +425,10 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, return false; } - WXDWORD exflags; - (void)MSWGetCreateWindowFlags(&exflags); - - if ( exflags ) - { - ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exflags); - ::SetWindowPos(GetHwnd(), - exflags & WS_EX_TOPMOST ? HWND_TOPMOST : 0, - 0, 0, 0, 0, - SWP_NOSIZE | - SWP_NOMOVE | - (exflags & WS_EX_TOPMOST ? 0 : SWP_NOZORDER) | - SWP_NOACTIVATE); - } - #if !defined(__WXWINCE__) // For some reason, the system menu is activated when we use the // WS_EX_CONTEXTHELP style, so let's set a reasonable icon - if ( exflags & WS_EX_CONTEXTHELP ) + if ( HasExtraStyle(wxWS_EX_CONTEXTHELP) ) { wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame); if ( winTop ) @@ -455,7 +442,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, } } } -#endif +#endif // !__WXWINCE__ // move the dialog to its initial position without forcing repainting int x, y, w, h; @@ -479,7 +466,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, if ( !title.empty() ) { - ::SetWindowText(GetHwnd(), title); + ::SetWindowText(GetHwnd(), title.wx_str()); } SubclassWin(m_hWnd); @@ -507,7 +494,7 @@ bool wxTopLevelWindowMSW::CreateFrame(const wxString& title, exflags |= WS_EX_LAYOUTRTL; #endif - return MSWCreate(wxCanvasClassName, title, pos, sz, flags, exflags); + return MSWCreate(wxCanvasClassName, title.wx_str(), pos, sz, flags, exflags); } bool wxTopLevelWindowMSW::Create(wxWindow *parent, @@ -561,7 +548,7 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, // reuse the code in MSWGetStyle() but correct the results slightly for // the dialog - dlgTemplate->style = MSWGetStyle(style, NULL); + dlgTemplate->style = MSWGetStyle(style, &dlgTemplate->dwExtendedStyle); // all dialogs are popups dlgTemplate->style |= WS_POPUP; @@ -673,10 +660,14 @@ bool wxTopLevelWindowMSW::Show(bool show) } else // just show { - if ( GetWindowStyle() & wxFRAME_TOOL_WINDOW ) - nShowCmd = SW_SHOWNA; - else - nShowCmd = SW_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 @@ -741,7 +732,8 @@ void wxTopLevelWindowMSW::Maximize(bool maximize) bool wxTopLevelWindowMSW::IsMaximized() const { return IsAlwaysMaximized() || -#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) +#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) && !defined(__WINCE_STANDARDSDK__) + (::IsZoomed(GetHwnd()) != 0) || #endif m_maximizeOnShow; @@ -947,7 +939,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) // finally send an event allowing the window to relayout itself &c wxSizeEvent event(rect.GetSize(), GetId()); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); } else // stop showing full screen { @@ -977,30 +969,26 @@ wxString wxTopLevelWindowMSW::GetTitle() const return GetLabel(); } -void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon) +void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons, + int smX, + int smY, + int i) { - SetIcons( wxIconBundle( icon ) ); + const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY)); + + const wxIcon icon = icons.GetIconOfExactSize(size); + if ( icon.Ok() ) + { + ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon)); + } } void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) { wxTopLevelWindowBase::SetIcons(icons); -#if !defined(__WXMICROWIN__) - const wxIcon& sml = icons.GetIcon( wxSize( 16, 16 ) ); - if( sml.Ok() && sml.GetWidth() == 16 && sml.GetHeight() == 16 ) - { - ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_SMALL, - (LPARAM)GetHiconOf(sml) ); - } - - const wxIcon& big = icons.GetIcon( wxSize( 32, 32 ) ); - if( big.Ok() && big.GetWidth() == 32 && big.GetHeight() == 32 ) - { - ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_BIG, - (LPARAM)GetHiconOf(big) ); - } -#endif // !__WXMICROWIN__ + DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL); + DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG); } bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) @@ -1092,7 +1080,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) // provide FlashWindowEx() declaration, so try to detect whether we have // real headers for WINVER 0x0500 by checking for existence of a symbol not // declated in MSVC6 header -#if defined(FLASHW_STOP) && defined(VK_XBUTTON1) +#if defined(FLASHW_STOP) && defined(VK_XBUTTON1) && wxUSE_DYNLIB_CLASS // available in the headers, check if it is supported by the system typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi); FlashWindowEx_t s_pfnFlashWindowEx = NULL; @@ -1138,6 +1126,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) { +#if wxUSE_DYNLIB_CLASS typedef DWORD (WINAPI *PSETLAYEREDWINDOWATTR)(HWND, DWORD, BYTE, DWORD); static PSETLAYEREDWINDOWATTR pSetLayeredWindowAttributes = NULL; @@ -1149,6 +1138,7 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) } if ( pSetLayeredWindowAttributes == NULL ) return false; +#endif // wxUSE_DYNLIB_CLASS LONG exstyle = GetWindowLong(GetHwnd(), GWL_EXSTYLE); @@ -1160,11 +1150,16 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) return true; } +#if wxUSE_DYNLIB_CLASS // Otherwise, set the layered style if needed and set the alpha value if ((exstyle & WS_EX_LAYERED) == 0 ) SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle | WS_EX_LAYERED); - return pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) != 0; + if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) ) + return true; +#endif // wxUSE_DYNLIB_CLASS + + return false; } bool wxTopLevelWindowMSW::CanSetTransparent() @@ -1180,6 +1175,55 @@ bool wxTopLevelWindowMSW::CanSetTransparent() return (os_type == wxOS_WINDOWS_NT && ver_major >= 5); } + +void wxTopLevelWindowMSW::DoFreeze() +{ + if ( IsShown() ) + { + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *child = node->GetData(); + if ( child->IsTopLevel() ) + continue; + + child->Freeze(); + } + } +} + +void wxTopLevelWindowMSW::DoThaw() +{ + if ( IsShown() ) + { + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *child = node->GetData(); + if ( child->IsTopLevel() ) + continue; + + child->Thaw(); + } + } +} + + +void wxTopLevelWindowMSW::AddChild(wxWindowBase *child) +{ + // adding a child while frozen will assert when thawn, so freeze it as if + // it had been already present when we were frozen + if ( child && !child->IsTopLevel() && IsFrozen() ) + { + child->Freeze(); + } + + wxTopLevelWindowBase::AddChild(child); +} + + // ---------------------------------------------------------------------------- // wxTopLevelWindow event handling // ----------------------------------------------------------------------------