fixes for Raise() to work correctly with both top level and child windows

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11430 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-08-20 23:02:27 +00:00
parent 5d987909a8
commit c48926e149
3 changed files with 34 additions and 30 deletions

View 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);

View 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);

View 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