2004-06-10 22:03:32 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "DialogDriver_Win32.h"
|
|
|
|
|
#include "RageUtil.h"
|
2005-12-28 05:42:22 +00:00
|
|
|
#if !defined(SMPACKAGE)
|
|
|
|
|
#include "CommonMetrics.h"
|
|
|
|
|
#endif
|
2005-01-08 14:32:42 +00:00
|
|
|
#include "ThemeManager.h"
|
2005-10-28 03:10:48 +00:00
|
|
|
#include "ProductInfo.h"
|
2004-06-10 22:03:32 +00:00
|
|
|
|
|
|
|
|
#include "archutils/win32/AppInstance.h"
|
|
|
|
|
#include "archutils/win32/GotoURL.h"
|
|
|
|
|
#include "archutils/win32/RestartProgram.h"
|
|
|
|
|
#include "archutils/win32/WindowsResources.h"
|
2005-12-28 05:42:22 +00:00
|
|
|
#if !defined(SMPACKAGE)
|
2005-02-07 09:16:00 +00:00
|
|
|
#include "archutils/win32/GraphicsWindow.h"
|
2005-12-28 05:42:22 +00:00
|
|
|
#endif
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:35:23 +00:00
|
|
|
static bool g_bHush;
|
2004-06-10 22:03:32 +00:00
|
|
|
static CString g_sMessage;
|
2005-06-03 23:35:23 +00:00
|
|
|
static bool g_bAllowHush;
|
2004-06-10 22:03:32 +00:00
|
|
|
|
|
|
|
|
static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|
|
|
|
{
|
|
|
|
|
switch( msg )
|
|
|
|
|
{
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
{
|
2005-06-03 23:42:07 +00:00
|
|
|
// Disable the parent window, like a modal MessageBox does.
|
2004-12-01 05:06:45 +00:00
|
|
|
EnableWindow( GetParent(hWnd), FALSE );
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:35:23 +00:00
|
|
|
// Hide or display "Don't show this message."
|
|
|
|
|
g_bHush = false;
|
|
|
|
|
HWND hHushButton = GetDlgItem( hWnd, IDC_HUSH );
|
|
|
|
|
int iStyle = GetWindowLong( hHushButton, GWL_STYLE );
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:35:23 +00:00
|
|
|
if( g_bAllowHush )
|
|
|
|
|
iStyle |= WS_VISIBLE;
|
2004-06-10 22:03:32 +00:00
|
|
|
else
|
2005-06-03 23:35:23 +00:00
|
|
|
iStyle &= ~WS_VISIBLE;
|
|
|
|
|
SetWindowLong( hHushButton, GWL_STYLE, iStyle );
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2004-12-01 05:06:45 +00:00
|
|
|
// Set static text.
|
|
|
|
|
CString sMessage = g_sMessage;
|
|
|
|
|
sMessage.Replace( "\n", "\r\n" );
|
|
|
|
|
SetWindowText( GetDlgItem(hWnd, IDC_MESSAGE), sMessage );
|
2004-12-01 05:28:08 +00:00
|
|
|
|
|
|
|
|
// Focus is on any of the controls in the dialog by default.
|
|
|
|
|
// I'm not sure why. Set focus to the button manually. -Chris
|
|
|
|
|
SetFocus( GetDlgItem(hWnd, IDOK) );
|
2004-12-01 05:06:45 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2005-06-03 23:35:23 +00:00
|
|
|
|
2004-12-01 05:06:45 +00:00
|
|
|
case WM_DESTROY:
|
2005-06-03 23:35:23 +00:00
|
|
|
// Re-enable the parent window.
|
|
|
|
|
EnableWindow( GetParent(hWnd), TRUE );
|
2004-06-10 22:03:32 +00:00
|
|
|
break;
|
2005-06-03 23:35:23 +00:00
|
|
|
|
2004-06-10 22:03:32 +00:00
|
|
|
case WM_COMMAND:
|
2005-06-03 23:35:23 +00:00
|
|
|
switch( LOWORD(wParam) )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
case IDOK:
|
2005-06-03 23:35:23 +00:00
|
|
|
g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH );
|
2004-06-10 22:03:32 +00:00
|
|
|
/* fall through */
|
|
|
|
|
case IDCANCEL:
|
|
|
|
|
EndDialog( hWnd, 0 );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-28 05:42:22 +00:00
|
|
|
static HWND GetHwnd()
|
|
|
|
|
{
|
|
|
|
|
#if !defined(SMPACKAGE)
|
|
|
|
|
return GraphicsWindow::GetHwnd();
|
|
|
|
|
#else
|
|
|
|
|
return NULL;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CString GetWindowTitle()
|
|
|
|
|
{
|
|
|
|
|
#if !defined(SMPACKAGE)
|
|
|
|
|
return CommonMetrics::WINDOW_TITLE.IsLoaded() ? CommonMetrics::WINDOW_TITLE.GetValue() : PRODUCT_NAME;
|
|
|
|
|
#else
|
|
|
|
|
return PRODUCT_NAME;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:42:07 +00:00
|
|
|
void DialogDriver_Win32::OK( CString sMessage, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-06-03 23:42:07 +00:00
|
|
|
g_bAllowHush = sID != "";
|
2004-06-10 22:03:32 +00:00
|
|
|
g_sMessage = sMessage;
|
|
|
|
|
AppInstance handle;
|
2005-12-28 05:42:22 +00:00
|
|
|
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_OK), ::GetHwnd(), OKWndProc );
|
2005-06-03 23:35:23 +00:00
|
|
|
if( g_bAllowHush && g_bHush )
|
2005-06-03 23:42:07 +00:00
|
|
|
Dialog::IgnoreMessage( sID );
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-28 05:42:22 +00:00
|
|
|
#if !defined(SMPACKAGE)
|
2004-06-10 22:03:32 +00:00
|
|
|
static CString g_sErrorString;
|
|
|
|
|
|
|
|
|
|
static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|
|
|
|
{
|
|
|
|
|
switch( msg )
|
|
|
|
|
{
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
{
|
2004-12-01 05:06:45 +00:00
|
|
|
// Set static text
|
2004-06-10 22:03:32 +00:00
|
|
|
CString sMessage = g_sErrorString;
|
|
|
|
|
sMessage.Replace( "\n", "\r\n" );
|
2004-12-01 05:06:45 +00:00
|
|
|
SetWindowText( GetDlgItem(hWnd, IDC_EDIT_ERROR), sMessage );
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_COMMAND:
|
2005-06-03 23:42:07 +00:00
|
|
|
switch( LOWORD(wParam) )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
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:
|
2005-10-28 03:10:48 +00:00
|
|
|
GotoURL( REPORT_BUG_URL );
|
2004-06-10 22:03:32 +00:00
|
|
|
break;
|
|
|
|
|
case IDC_BUTTON_RESTART:
|
|
|
|
|
Win32RestartProgram();
|
|
|
|
|
/* not reached */
|
|
|
|
|
ASSERT( 0 );
|
|
|
|
|
|
|
|
|
|
EndDialog( hWnd, 0 );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case IDOK:
|
|
|
|
|
EndDialog( hWnd, 0 );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2005-12-28 05:42:22 +00:00
|
|
|
#endif
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:42:07 +00:00
|
|
|
void DialogDriver_Win32::Error( CString sError, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-12-28 05:42:22 +00:00
|
|
|
#if !defined(SMPACKAGE)
|
2005-06-03 23:42:07 +00:00
|
|
|
g_sErrorString = sError;
|
|
|
|
|
|
|
|
|
|
// throw up a pretty error dialog
|
2004-06-10 22:03:32 +00:00
|
|
|
AppInstance handle;
|
2005-06-03 23:35:23 +00:00
|
|
|
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG), NULL, ErrorWndProc );
|
2005-12-28 05:42:22 +00:00
|
|
|
#endif
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dialog::Result DialogDriver_Win32::AbortRetryIgnore( CString sMessage, CString ID )
|
|
|
|
|
{
|
2005-12-28 05:42:22 +00:00
|
|
|
switch( MessageBox(::GetHwnd(), sMessage, ::GetWindowTitle(), MB_ABORTRETRYIGNORE|MB_DEFBUTTON3 ) )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
case IDABORT: return Dialog::abort;
|
|
|
|
|
case IDRETRY: return Dialog::retry;
|
|
|
|
|
default: ASSERT(0);
|
|
|
|
|
case IDIGNORE: return Dialog::ignore;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-03 23:42:07 +00:00
|
|
|
Dialog::Result DialogDriver_Win32::AbortRetry( CString sMessage, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-12-28 05:42:22 +00:00
|
|
|
switch( MessageBox(::GetHwnd(), sMessage, ::GetWindowTitle(), MB_RETRYCANCEL) )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
case IDRETRY: return Dialog::retry;
|
|
|
|
|
default: ASSERT(0);
|
2005-01-20 19:40:24 +00:00
|
|
|
case IDCANCEL: return Dialog::abort;
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|