mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-19 03:39:08 +00:00
Merge pull request #209 from Hoikas/fullscreen-error
Fix for Hidden MessageBoxes
This commit is contained in:
@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,9 +70,34 @@ char *hsScalarToStr(float s)
|
|||||||
return hsStrBuf;
|
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;
|
bool hsMessageBox_SuppressPrompts = false;
|
||||||
|
|
||||||
int hsMessageBoxWithOwner(void * owner, const char message[], const char caption[], int kind, int icon)
|
int hsMessageBoxWithOwner(hsWindowHndl owner, const char message[], const char caption[], int kind, int icon)
|
||||||
{
|
{
|
||||||
if (hsMessageBox_SuppressPrompts)
|
if (hsMessageBox_SuppressPrompts)
|
||||||
return hsMBoxOk;
|
return hsMBoxOk;
|
||||||
@ -106,10 +131,8 @@ int hsMessageBoxWithOwner(void * owner, const char message[], const char caption
|
|||||||
else
|
else
|
||||||
flags |= MB_ICONERROR;
|
flags |= MB_ICONERROR;
|
||||||
|
|
||||||
#ifdef CLIENT
|
hsMinimizeClientGuard guard;
|
||||||
ErrorMinimizeAppWindow();
|
int ans = MessageBox(owner, message, caption, flags);
|
||||||
#endif
|
|
||||||
int ans = MessageBox((HWND)owner, message, caption, flags);
|
|
||||||
|
|
||||||
switch (ans)
|
switch (ans)
|
||||||
{
|
{
|
||||||
@ -126,7 +149,7 @@ int hsMessageBoxWithOwner(void * owner, const char message[], const char caption
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int hsMessageBoxWithOwner(void * owner, const wchar_t message[], const wchar_t caption[], int kind, int icon)
|
int hsMessageBoxWithOwner(hsWindowHndl owner, const wchar_t message[], const wchar_t caption[], int kind, int icon)
|
||||||
{
|
{
|
||||||
if (hsMessageBox_SuppressPrompts)
|
if (hsMessageBox_SuppressPrompts)
|
||||||
return hsMBoxOk;
|
return hsMBoxOk;
|
||||||
@ -160,10 +183,8 @@ int hsMessageBoxWithOwner(void * owner, const wchar_t message[], const wchar_t c
|
|||||||
else
|
else
|
||||||
flags |= MB_ICONERROR;
|
flags |= MB_ICONERROR;
|
||||||
|
|
||||||
#ifdef CLIENT
|
hsMinimizeClientGuard guard;
|
||||||
ErrorMinimizeAppWindow();
|
int ans = MessageBoxW(owner, message, caption, flags);
|
||||||
#endif
|
|
||||||
int ans = MessageBoxW((HWND)owner, message, caption, flags);
|
|
||||||
|
|
||||||
switch (ans)
|
switch (ans)
|
||||||
{
|
{
|
||||||
@ -182,20 +203,12 @@ int hsMessageBoxWithOwner(void * owner, const wchar_t message[], const wchar_t c
|
|||||||
|
|
||||||
int hsMessageBox(const char message[], const char caption[], int kind, int icon)
|
int hsMessageBox(const char message[], const char caption[], int kind, int icon)
|
||||||
{
|
{
|
||||||
#if HS_BUILD_FOR_WIN32
|
return hsMessageBoxWithOwner((hsWindowHndl)nil,message,caption,kind,icon);
|
||||||
return hsMessageBoxWithOwner(nil/*GetActiveWindow()*/,message,caption,kind,icon);
|
|
||||||
#else
|
|
||||||
return hsMessageBoxWithOwner(nil,message,caption,kind,icon);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int icon)
|
int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int icon)
|
||||||
{
|
{
|
||||||
#if HS_BUILD_FOR_WIN32
|
return hsMessageBoxWithOwner((hsWindowHndl)nil,message,caption,kind,icon);
|
||||||
return hsMessageBoxWithOwner(nil/*GetActiveWindow()*/,message,caption,kind,icon);
|
|
||||||
#else
|
|
||||||
return hsMessageBoxWithOwner(nil,message,caption,kind,icon);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline hsBool hsCompare(float a, float b, float delta)
|
inline hsBool hsCompare(float a, float b, float delta)
|
||||||
|
@ -126,8 +126,8 @@ enum { // RETURN VALUES FROM hsMessageBox
|
|||||||
extern bool hsMessageBox_SuppressPrompts;
|
extern bool hsMessageBox_SuppressPrompts;
|
||||||
int hsMessageBox(const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
int hsMessageBox(const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
||||||
int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
||||||
int hsMessageBoxWithOwner(void* owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
int hsMessageBoxWithOwner(hsWindowHndl owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
||||||
int hsMessageBoxWithOwner(void* owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
int hsMessageBoxWithOwner(hsWindowHndl owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
|
||||||
|
|
||||||
inline hsBool hsCompare(float a, float b, float delta=0.0001);
|
inline hsBool hsCompare(float a, float b, float delta=0.0001);
|
||||||
|
|
||||||
@ -217,7 +217,6 @@ hsDebugMessageProc hsSetStatusMessageProc(hsDebugMessageProc newProc);
|
|||||||
|
|
||||||
void ErrorEnableGui (bool enabled);
|
void ErrorEnableGui (bool enabled);
|
||||||
void ErrorAssert (int line, const char file[], const char fmt[], ...);
|
void ErrorAssert (int line, const char file[], const char fmt[], ...);
|
||||||
void ErrorMinimizeAppWindow ();
|
|
||||||
|
|
||||||
bool DebugIsDebuggerPresent ();
|
bool DebugIsDebuggerPresent ();
|
||||||
void DebugBreakIfDebuggerPresent ();
|
void DebugBreakIfDebuggerPresent ();
|
||||||
|
Reference in New Issue
Block a user