]> git.saurik.com Git - wxWidgets.git/commitdiff
fixes for Raise() to work correctly with both top level and child windows
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Aug 2001 23:02:27 +0000 (23:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Aug 2001 23:02:27 +0000 (23:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11430 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/frame.h
src/msw/frame.cpp
src/msw/window.cpp

index 22509da92084c554c1400ef5ea989e4bf64bac04..abd5752e93683a1b31b97acee4a67d4e5a6b5b88 100644 (file)
@@ -45,6 +45,7 @@ public:
     virtual ~wxFrameMSW();
 
     // implement base class pure virtuals
+    virtual void Raise();
     virtual void Maximize(bool maximize = TRUE);
     virtual bool IsMaximized() const;
     virtual void Iconize(bool iconize = TRUE);
index b1b4e12a8f33eed69283fb9621ac9176613a08c1..7013f9d85df6a6fee359381494e6fad7ac832cf2 100644 (file)
@@ -347,6 +347,16 @@ bool wxFrameMSW::Show(bool show)
     return TRUE;
 }
 
+void wxFrameMSW::Raise()
+{
+#ifdef __WIN16__
+    // no SetForegroundWindow() in Win16
+    wxFrameBase::Raise();
+#else // Win32
+    ::SetForegroundWindow(GetHwnd());
+#endif // Win16/32
+}
+
 void wxFrameMSW::Iconize(bool iconize)
 {
     DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
index 3d030562ba8d4cf75e6461be55d441d54d3ee738..0ba56334b2825c6ca953b7fa04d55e4d2660e338 100644 (file)
@@ -157,7 +157,27 @@ static void TranslateKbdEventToMouse(wxWindowMSW *win,
 static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
 
 // check if the mouse is in the window or its child
-//static bool IsMouseInWindow(HWND hwnd);
+static bool IsMouseInWindow(HWND hwnd);
+
+// wrapper around BringWindowToTop() API
+static inline wxBringWindowToTop(HWND hwnd)
+{
+#ifdef __WXMICROWIN__
+    // It seems that MicroWindows brings the _parent_ of the window to the top,
+    // which can be the wrong one.
+
+    // activate (set focus to) specified window
+    ::SetFocus(hwnd);
+
+    // raise top level parent to top of z order
+    ::SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+#else // !__WXMICROWIN__
+    if ( !::BringWindowToTop(hwnd) )
+    {
+        wxLogLastError(_T("BringWindowToTop"));
+    }
+#endif // __WXMICROWIN__/!__WXMICROWIN__
+}
 
 // ---------------------------------------------------------------------------
 // event tables
@@ -503,19 +523,7 @@ bool wxWindowMSW::Show(bool show)
 
     if ( show )
     {
-#ifdef __WXMICROWIN__
-        // It seems that MicroWindows brings the _parent_ of the
-        // window to the top, which can be the wrong one.
-
-        // activate (set focus to) specified window
-        ::SetFocus(hWnd);
-
-        // raise top level parent to top of z order
-        ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
-                SWP_NOMOVE|SWP_NOSIZE);
-#else
-        BringWindowToTop(hWnd);
-#endif
+        wxBringWindowToTop(hWnd);
     }
 
     return TRUE;
@@ -524,22 +532,7 @@ bool wxWindowMSW::Show(bool show)
 // Raise the window to the top of the Z order
 void wxWindowMSW::Raise()
 {
-#ifdef __WIN16__
-    ::BringWindowToTop(GetHwnd());
-#else // Win32
-#ifdef __WXMICROWIN__
-    // It seems that MicroWindows brings the _parent_ of the
-    // window to the top, which can be the wrong one.
-
-    // activate (set focus to) specified window
-    ::SetFocus(GetHwnd());
-
-    // raise top level parent to top of z order
-    ::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
-#else
-    ::SetForegroundWindow(GetHwnd());
-#endif
-#endif
+    wxBringWindowToTop(GetHwnd());
 }
 
 // Lower the window to the bottom of the Z order