1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Fullscreen clients no longer hide message boxes

The old solution may have worked at one point in time, but it was kind of
suspect in that it would (theoretically) hide the game window forever. The
new solution will only hide the game window while the message box is
alive. As a bonus, the part where we hide the full screen window now
works.
This commit is contained in:
2012-06-09 23:24:59 -04:00
parent fac4448850
commit 4ba4ca7fee
3 changed files with 27 additions and 24 deletions

View File

@ -175,23 +175,6 @@ void DebugMsg(const char fmt[], ...)
}
}
void ErrorMinimizeAppWindow ()
{
#ifdef HS_BUILD_FOR_WIN32
// If the application's topmost window is a fullscreen
// popup window, minimize it before displaying an error
HWND appWindow = GetActiveWindow();
if ( ((GetWindowLong(appWindow, GWL_STYLE) & WS_POPUP) != 0) )
SetWindowPos(
appWindow,
HWND_NOTOPMOST,
0, 0, // position
0, 0, // size
SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE
);
#endif
}
///////////////////////////////////////////////////////////////////

View File

@ -70,6 +70,31 @@ char *hsScalarToStr(float s)
return hsStrBuf;
}
class hsMinimizeClientGuard
{
#ifdef CLIENT
hsWindowHndl fWnd;
public:
hsMinimizeClientGuard()
{
#ifdef HS_BUILD_FOR_WIN32
fWnd = GetActiveWindow();
// If the application's topmost window is fullscreen, minimize it before displaying an error
if ((GetWindowLong(fWnd, GWL_STYLE) & WS_POPUP) != 0)
ShowWindow(fWnd, SW_MINIMIZE);
#endif // HS_BUILD_FOR_WIN32
}
~hsMinimizeClientGuard()
{
#ifdef HS_BUILD_FOR_WIN32
ShowWindow(fWnd, SW_RESTORE);
#endif // HS_BUILD_FOR_WIN32
}
#endif // CLIENT
};
bool hsMessageBox_SuppressPrompts = false;
int hsMessageBoxWithOwner(void * owner, const char message[], const char caption[], int kind, int icon)
@ -106,9 +131,7 @@ int hsMessageBoxWithOwner(void * owner, const char message[], const char caption
else
flags |= MB_ICONERROR;
#ifdef CLIENT
ErrorMinimizeAppWindow();
#endif
hsMinimizeClientGuard guard;
int ans = MessageBox((HWND)owner, message, caption, flags);
switch (ans)
@ -160,9 +183,7 @@ int hsMessageBoxWithOwner(void * owner, const wchar_t message[], const wchar_t c
else
flags |= MB_ICONERROR;
#ifdef CLIENT
ErrorMinimizeAppWindow();
#endif
hsMinimizeClientGuard guard;
int ans = MessageBoxW((HWND)owner, message, caption, flags);
switch (ans)

View File

@ -217,7 +217,6 @@ hsDebugMessageProc hsSetStatusMessageProc(hsDebugMessageProc newProc);
void ErrorEnableGui (bool enabled);
void ErrorAssert (int line, const char file[], const char fmt[], ...);
void ErrorMinimizeAppWindow ();
bool DebugIsDebuggerPresent ();
void DebugBreakIfDebuggerPresent ();