X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17808a759627b03c2acbe7333dd2386557e1b804..697c314b162ff4758db0047e548d5401994d2c70:/src/msw/toplevel.cpp?ds=sidebyside diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 8a22cb54a1..faa55fe617 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -507,9 +507,6 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, { bool ret wxDUMMY_INITIALIZE(false); - // init our fields - Init(); - wxSize sizeReal = size; if ( !sizeReal.IsFullySpecified() ) { @@ -548,7 +545,13 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, // reuse the code in MSWGetStyle() but correct the results slightly for // the dialog - dlgTemplate->style = MSWGetStyle(style, &dlgTemplate->dwExtendedStyle); + // + // NB: we need a temporary variable as we can't pass pointer to + // dwExtendedStyle directly, it's not aligned correctly for 64 bit + // architectures + WXDWORD dwExtendedStyle; + dlgTemplate->style = MSWGetStyle(style, &dwExtendedStyle); + dlgTemplate->dwExtendedStyle = dwExtendedStyle; // all dialogs are popups dlgTemplate->style |= WS_POPUP; @@ -660,10 +663,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 @@ -1079,7 +1086,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags) #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; + static FlashWindowEx_t s_pfnFlashWindowEx = NULL; if ( !s_pfnFlashWindowEx ) { wxDynamicLibrary dllUser32(_T("user32.dll")); @@ -1174,49 +1181,14 @@ bool wxTopLevelWindowMSW::CanSetTransparent() 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(); - } - } + // do nothing: freezing toplevel window causes paint and mouse events + // to go through it any TLWs under it, so the best we can do is to freeze + // all children -- and wxWindowBase::Freeze() does that } 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); + // intentionally empty -- see DoFreeze() } @@ -1232,7 +1204,7 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) { // restore focus to the child which was last focused unless we already // have it - wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd); + wxLogTrace(_T("focus"), _T("wxTLW %p activated."), m_hWnd); wxWindow *winFocus = FindFocus(); if ( !winFocus || wxGetTopLevelParent(winFocus) != this ) @@ -1255,7 +1227,9 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) if ( m_winLastFocused ) { // let it know that it doesn't have focus any more - m_winLastFocused->HandleKillFocus((WXHWND)NULL); + // But this will already be done via WM_KILLFOCUS, so we'll get two kill + // focus events if we call it explicitly. + // m_winLastFocused->HandleKillFocus((WXHWND)NULL); // and don't remember it if it's a child from some other frame if ( wxGetTopLevelParent(m_winLastFocused) != this ) @@ -1265,10 +1239,9 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) } wxLogTrace(_T("focus"), - _T("wxTLW %08x deactivated, last focused: %08x."), - (int) m_hWnd, - (int) (m_winLastFocused ? GetHwndOf(m_winLastFocused) - : NULL)); + _T("wxTLW %p deactivated, last focused: %p."), + m_hWnd, + m_winLastFocused ? GetHwndOf(m_winLastFocused) : NULL); event.Skip(); }