http://bugs.winehq.org/show_bug.cgi?id=5725
Summary: Code for undocumented SwitchToThisWindow function does not reflect empirical evidence Product: Wine Version: unspecified Platform: All URL: http://source.winehq.org/source/dlls/user/winpos.c#L153 OS/Version: All Status: UNCONFIRMED Severity: minor Priority: P2 Component: wine-gui AssignedTo: wine-bugs@winehq.org ReportedBy: neil@parkwaycc.co.uk
void WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore ) { ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED ); } 1. SwitchToThisWindow never minimizes a window 2. The restore flag only applies to minimised windows 3. If restore is false then the foreground window is sent to the back (even if it was the hwnd) unless it is a topmost window. So, the code should look something like this: void WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore ) { HWND hwndOld = GetForegroundWindow(); SetForegroundWindow( hWnd ); if ( restore ) { if ( IsIconic( hwnd ) ) ShowWindow( hwnd, SW_RESTORE ); } else { if ( !( GetWindowLong( hwndOld, GWL_EXSTYLE ) & WS_EX_TOPMOST ) ) SetWindowPos( hWndOld, HWNDBOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); } } (sorry I don't know a better way of testing for a topmost window)