]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
Remove always moving window to the top of the Z-order on on Show
[wxWidgets.git] / src / msw / toplevel.cpp
index 04f8e5de1f455282669b236747d9e16da65541c0..2a76e65ebb1fd5a4c275ed39abfa5b35f7b97911 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        msw/toplevel.cpp
+// Name:        src/msw/toplevel.cpp
 // Purpose:     implements wxTopLevelWindow for MSW
 // Author:      Vadim Zeitlin
 // Modified by:
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "toplevel.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -209,7 +205,7 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
     if ( style & wxMAXIMIZE_BOX )
         msflags |= WS_MAXIMIZEBOX;
 
-#ifndef __WXWINCE__    
+#ifndef __WXWINCE__
     if ( style & wxSYSTEM_MENU )
         msflags |= WS_SYSMENU;
 #endif
@@ -418,11 +414,11 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
     }
 
     SubclassWin(m_hWnd);
-    
+
 #ifdef __SMARTPHONE__
     // Work around title non-display glitch
     Show(false);
-#endif    
+#endif
 
     return true;
 #endif // __WXMICROWIN__/!__WXMICROWIN__
@@ -527,21 +523,13 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
     }
 #endif
 
-    // for some reason we need to manually send ourselves this message as
-    // otherwise the mnemonics are always shown -- even if they're configured
-    // to be hidden until "Alt" is pressed in the control panel
-    //
-    // this could indicate a bug somewhere else but for now this is the only
-    // fix we have
+    // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
+    // itself but for custom windows we have to do it ourselves in order to
+    // make the keyboard indicators (such as underlines for accelerators and
+    // focus rectangles) work under Win2k+
     if ( ret )
     {
-        ::SendMessage
-        (
-            GetHwnd(),
-            WM_UPDATEUISTATE,
-            MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS | UISF_HIDEACCEL),
-            0
-        );
+        MSWUpdateUIState(UIS_INITIALIZE);
     }
 
     // Note: if we include PocketPC in this test, dialogs can fail to show up,
@@ -668,6 +656,14 @@ void wxTopLevelWindowMSW::Maximize(bool maximize)
         // we can't maximize the hidden frame because it shows it as well, so
         // just remember that we should do it later in this case
         m_maximizeOnShow = maximize;
+
+        // after calling Maximize() the client code expects to get the frame
+        // "real" size and doesn't want to know that, because of implementation
+        // details, the frame isn't really maximized yet but will be only once
+        // it's shown, so return our size as it will be then in this case
+
+        // we don't know which display we're on yet so use the default one
+        SetSize(wxGetClientDisplayRect().GetSize());
     }
 }
 
@@ -676,7 +672,7 @@ bool wxTopLevelWindowMSW::IsMaximized() const
 #ifdef __WXWINCE__
     return false;
 #else
-    return ::IsZoomed(GetHwnd()) != 0;
+    return m_maximizeOnShow || ::IsZoomed(GetHwnd()) != 0;
 #endif
 }
 
@@ -757,7 +753,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
             rect = wxDisplay(dpy).GetGeometry();
         }
         else // fall back to the main desktop
-#else // wxUSE_DISPLAY
+#endif // wxUSE_DISPLAY
         {
             // resize to the size of the desktop
             wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
@@ -768,7 +764,6 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
             rect.y       = 0;
 #endif
         }
-#endif // wxUSE_DISPLAY
 
         SetSize(rect);
 
@@ -818,6 +813,16 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
 // wxTopLevelWindowMSW misc
 // ----------------------------------------------------------------------------
 
+void wxTopLevelWindowMSW::SetTitle( const wxString& title)
+{
+    SetLabel(title);
+}
+
+wxString wxTopLevelWindowMSW::GetTitle() const
+{
+    return GetLabel();
+}
+
 void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon)
 {
     SetIcons( wxIconBundle( icon ) );
@@ -928,10 +933,12 @@ bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
 
 void wxTopLevelWindowMSW::RequestUserAttention(int flags)
 {
-    // check if we can use FlashWindowEx(): unfortunately an explicit test for
-    // FLASHW_STOP, for example, doesn't work because MSVC6 headers do #define
-    // it but don't provide FlashWindowEx() declaration
-#if (WINVER >= 0x0500 && (defined FLASHW_STOP))
+    // check if we can use FlashWindowEx(): unfortunately a simple test for
+    // FLASHW_STOP doesn't work because MSVC6 headers do #define it but don't
+    // 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)
     // available in the headers, check if it is supported by the system
     typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi);
     FlashWindowEx_t s_pfnFlashWindowEx = NULL;
@@ -941,7 +948,7 @@ void wxTopLevelWindowMSW::RequestUserAttention(int flags)
         s_pfnFlashWindowEx = (FlashWindowEx_t)
                                 dllUser32.GetSymbol(_T("FlashWindowEx"));
 
-        // we can safely unload user32.dll here, it's goign to remain loaded as
+        // we can safely unload user32.dll here, it's going to remain loaded as
         // long as the program is running anyhow
     }
 
@@ -1143,5 +1150,3 @@ HWND wxTLWHiddenParentModule::GetHWND()
 
     return ms_hwnd;
 }
-
-