Files
itgmania212121/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp
T

196 lines
4.4 KiB
C++
Raw Normal View History

2003-02-16 04:02:21 +00:00
#include "global.h"
#include "ArchHooks_Win32.h"
#include "RageUtil.h"
#include "PrefsManager.h"
#include "resource.h"
#include "archutils/win32/AppInstance.h"
#include "archutils/win32/crash.h"
2003-01-24 23:57:02 +00:00
#include "archutils/win32/DebugInfoHunt.h"
2003-09-23 05:06:13 +00:00
#include "archutils/win32/GotoURL.h"
2003-09-21 02:34:51 +00:00
#include "ProductInfo.h"
ArchHooks_Win32::ArchHooks_Win32()
{
SetUnhandledExceptionFilter(CrashHandler);
}
2003-02-17 03:08:53 +00:00
void ArchHooks_Win32::DumpDebugInfo()
2003-01-24 23:57:02 +00:00
{
/* This is a good time to do the debug search: before we actually
* start OpenGL (in case something goes wrong). */
SearchForDebugInfo();
}
static CString g_sMessage;
static bool g_AllowHush;
static bool g_Hush;
static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_INITDIALOG:
{
g_Hush = false;
CString sMessage = g_sMessage;
sMessage.Replace( "\n", "\r\n" );
HWND hush = GetDlgItem( hWnd, IDC_HUSH );
int style = GetWindowLong(hush, GWL_STYLE);
if( g_AllowHush )
style |= WS_VISIBLE;
else
style &= ~WS_VISIBLE;
SetWindowLong( hush, GWL_STYLE, style );
SendDlgItemMessage(
hWnd,
IDC_MESSAGE,
WM_SETTEXT,
0,
(LPARAM)(LPCTSTR)sMessage
);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
g_Hush = !!IsDlgButtonChecked(hWnd, IDC_HUSH);
/* fall through */
case IDCANCEL:
EndDialog( hWnd, 0 );
break;
}
}
return FALSE;
}
void ArchHooks_Win32::MessageBoxOK( CString sMessage, CString ID )
{
g_AllowHush = ID != "";
if( g_AllowHush && MessageIsIgnored( ID ) )
return;
g_sMessage = sMessage;
AppInstance handle;
DialogBox(handle.Get(), MAKEINTRESOURCE(IDD_OK), NULL, OKWndProc);
if( g_AllowHush && g_Hush )
IgnoreMessage( ID );
}
2003-09-23 05:06:13 +00:00
static CString g_sErrorString;
static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_INITDIALOG:
{
CString sMessage = g_sErrorString;
sMessage.Replace( "\n", "\r\n" );
SendDlgItemMessage(
hWnd,
IDC_EDIT_ERROR,
WM_SETTEXT,
0,
(LPARAM)(LPCTSTR)sMessage
);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_BUTTON_VIEW_LOG:
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
CreateProcess(
NULL, // pointer to name of executable module
"notepad.exe log.txt", // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
false, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
}
break;
case IDC_BUTTON_REPORT:
GotoURL( "http://sourceforge.net/tracker/?func=add&group_id=37892&atid=421366" );
break;
case IDC_BUTTON_RESTART:
{
/* Clear the startup mutex, since we're starting a new
* instance before ending ourself. */
TCHAR szFullAppPath[MAX_PATH];
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
// Launch StepMania
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
CreateProcess(
NULL, // pointer to name of executable module
szFullAppPath, // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
false, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
}
EndDialog( hWnd, 0 );
break;
2003-09-23 05:14:41 +00:00
2003-09-23 05:06:13 +00:00
case IDOK:
EndDialog( hWnd, 0 );
break;
}
}
return FALSE;
}
void ArchHooks_Win32::MessageBoxError( CString error )
{
g_sErrorString = error;
// throw up a pretty error dialog
AppInstance handle;
DialogBox(handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG),
NULL, ErrorWndProc);
}
ArchHooks::MessageBoxResult ArchHooks_Win32::MessageBoxAbortRetryIgnore( CString sMessage, CString ID )
{
2003-09-21 02:34:51 +00:00
switch( MessageBox(NULL, sMessage, PRODUCT_NAME, MB_ABORTRETRYIGNORE ) )
{
case IDABORT: return abort;
case IDRETRY: return retry;
default: ASSERT(0);
case IDIGNORE: return ignore;
}
}
2003-09-23 05:06:13 +00:00
/*
* Copyright (c) 2002-2003 by the person(s) listed below. All rights reserved.
*
* Glenn Maynard
2003-07-22 07:47:27 +00:00
* Chris Danford
*/