]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
added wxRESERVE_SPACE_EVEN_IF_HIDDEN sizer flag that prevents the sizer from changing...
[wxWidgets.git] / src / msw / toplevel.cpp
index 359c874cb8942ee0ea0080e69a64953a952750f9..f87a9827358e98aedce67319b35455759fd780bf 100644 (file)
@@ -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;
@@ -520,9 +507,6 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
 {
     bool ret wxDUMMY_INITIALIZE(false);
 
-    // init our fields
-    Init();
-
     wxSize sizeReal = size;
     if ( !sizeReal.IsFullySpecified() )
     {
@@ -561,7 +545,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 +657,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 +729,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 +936,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,25 +966,26 @@ wxString wxTopLevelWindowMSW::GetTitle() const
     return GetLabel();
 }
 
-void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
+void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
+                                             int smX,
+                                             int smY,
+                                             int i)
 {
-    wxTopLevelWindowBase::SetIcons(icons);
+    const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));
 
-#if !defined(__WXMICROWIN__)
-    const wxIcon& sml = icons.GetIconOfExactSize(16);
-    if( sml.Ok() )
+    const wxIcon icon = icons.GetIconOfExactSize(size);
+    if ( icon.Ok() )
     {
-        ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_SMALL,
-                       (LPARAM)GetHiconOf(sml) );
+        ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
     }
+}
 
-    const wxIcon& big = icons.GetIconOfExactSize(32);
-    if( big.Ok() )
-    {
-        ::SendMessage( GetHwndOf( this ), WM_SETICON, ICON_BIG,
-                       (LPARAM)GetHiconOf(big) );
-    }
-#endif // !__WXMICROWIN__
+void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
+{
+    wxTopLevelWindowBase::SetIcons(icons);
+
+    DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
+    DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
 }
 
 bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
@@ -1182,6 +1172,20 @@ bool wxTopLevelWindowMSW::CanSetTransparent()
     return (os_type == wxOS_WINDOWS_NT && ver_major >= 5);
 }
 
+
+void wxTopLevelWindowMSW::DoFreeze()
+{
+    // 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()
+{
+    // intentionally empty -- see DoFreeze()
+}
+
+
 // ----------------------------------------------------------------------------
 // wxTopLevelWindow event handling
 // ----------------------------------------------------------------------------
@@ -1194,7 +1198,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 )
@@ -1227,10 +1231,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();
     }