2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-05-22 04:47:15 +00:00
|
|
|
#include "stdafx.h"
|
2015-02-13 19:40:25 +00:00
|
|
|
#include "Settings/SettingType/SettingsType-Application.h"
|
2010-05-22 04:47:15 +00:00
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
void EnterLogOptions(HWND hwndOwner);
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma comment(lib, "Comctl32.lib")
|
|
|
|
|
|
|
|
DWORD CALLBACK AboutBoxProc (HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam);
|
2015-01-27 05:07:44 +00:00
|
|
|
DWORD CALLBACK MainGui_Proc (HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) :
|
|
|
|
CRomBrowser(m_hMainWindow,m_hStatusWnd),
|
2013-01-03 08:51:00 +00:00
|
|
|
m_ThreadId(GetCurrentThreadId()),
|
2015-02-13 19:40:25 +00:00
|
|
|
m_bMainWindow(bMainWindow),
|
|
|
|
m_Created(false),
|
|
|
|
m_AttachingMenu(false),
|
|
|
|
m_MakingVisible(false)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
m_hacked = false;
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (MD5(g_Settings->LoadString(Beta_UserName)).hex_digest() != g_Settings->LoadString(Beta_UserNameMD5) ||
|
|
|
|
MD5(g_Settings->LoadString(Beta_EmailAddress)).hex_digest() != g_Settings->LoadString(Beta_EmailAddressMD5))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
m_hacked = true;
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Menu = NULL;
|
|
|
|
|
|
|
|
m_hMainWindow = 0;
|
|
|
|
m_hStatusWnd = 0;
|
|
|
|
m_SaveMainWindowPos = false;
|
|
|
|
m_SaveMainWindowTop = 0;
|
|
|
|
m_SaveMainWindowLeft = 0;
|
|
|
|
|
|
|
|
m_SaveRomBrowserPos = false;
|
|
|
|
m_SaveRomBrowserTop = 0;
|
|
|
|
m_SaveRomBrowserLeft = 0;
|
|
|
|
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
m_InvalidExeMsg = RegisterWindowMessage("Invalid");
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
if (m_bMainWindow)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->RegisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged);
|
|
|
|
g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
|
|
|
g_Settings->RegisterChangeCB(RomBrowser_Recursive,this,(CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
//if this fails then it has already been created
|
|
|
|
RegisterWinClass();
|
|
|
|
Create(WindowTitle);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CMainGui::~CMainGui (void)
|
|
|
|
{
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Start");
|
2010-05-22 04:47:15 +00:00
|
|
|
if (m_bMainWindow)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->UnregisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(RomBrowser_Recursive,this,(CSettings::SettingChangedFunc)RomBrowserRecursiveChanged);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
if (m_hMainWindow)
|
|
|
|
{
|
|
|
|
DestroyWindow((HWND)m_hMainWindow);
|
|
|
|
}
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
bool CMainGui::RegisterWinClass ( void )
|
|
|
|
{
|
|
|
|
WNDCLASS wcl;
|
|
|
|
|
|
|
|
wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wcl.cbClsExtra = 0;
|
|
|
|
wcl.cbWndExtra = 0;
|
|
|
|
wcl.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_PJ64_Icon));
|
|
|
|
wcl.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
|
|
wcl.hInstance = GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
wcl.lpfnWndProc = (WNDPROC)MainGui_Proc;
|
|
|
|
wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
|
|
|
wcl.lpszMenuName = NULL;
|
|
|
|
wcl.lpszClassName = "Project64 2.0";
|
|
|
|
if (RegisterClass(&wcl) == 0) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
void RomBowserEnabledChanged (CMainGui * Gui)
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (Gui && g_Settings->LoadBool(RomBrowser_Enabled))
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if (!Gui->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
Gui->ShowRomList();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Gui->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
Gui->HideRomList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RomBowserColoumnsChanged (CMainGui * Gui)
|
|
|
|
{
|
|
|
|
Gui->ResetRomBrowserColomuns();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RomBrowserRecursiveChanged (CMainGui * Gui)
|
|
|
|
{
|
|
|
|
Gui->RefreshRomBrowser();
|
|
|
|
Gui->HighLightLastRom();
|
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
void CMainGui::ChangeWinSize (long width, long height) {
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
WINDOWPLACEMENT wndpl;
|
|
|
|
RECT rc1, swrect;
|
|
|
|
|
|
|
|
wndpl.length = sizeof(wndpl);
|
|
|
|
GetWindowPlacement( (HWND)m_hMainWindow, &wndpl);
|
|
|
|
|
|
|
|
if ( (HWND)m_hStatusWnd != NULL ) {
|
|
|
|
GetClientRect( (HWND)m_hStatusWnd, &swrect );
|
|
|
|
SetRect( &rc1, 0, 0, width, height + swrect.bottom );
|
|
|
|
} else {
|
|
|
|
SetRect( &rc1, 0, 0, width, height );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AdjustWindowRectEx( &rc1,GetWindowLong( (HWND)m_hMainWindow, GWL_STYLE ),
|
|
|
|
GetMenu( (HWND)m_hMainWindow ) != NULL, GetWindowLong( (HWND)m_hMainWindow, GWL_EXSTYLE ) );
|
|
|
|
|
|
|
|
MoveWindow( (HWND)m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top,
|
|
|
|
rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::AboutBox (void) {
|
|
|
|
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About), (HWND)m_hMainWindow, (DLGPROC)AboutBoxProc,(LPARAM)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::AboutIniBox (void) {
|
|
|
|
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), (HWND)m_hMainWindow, (DLGPROC)AboutIniBoxProc,(LPARAM)this);
|
|
|
|
}
|
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
DWORD CALLBACK AboutIniBoxProc (HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) {
|
2008-09-18 03:15:49 +00:00
|
|
|
static char RDBHomePage[300], CHTHomePage[300], RDXHomePage[300];
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
HWND hDlg = (HWND)WndHandle;
|
|
|
|
char String[200],String2[200];
|
|
|
|
|
|
|
|
SetWindowText(hDlg, GS(INI_TITLE));
|
|
|
|
//Language
|
|
|
|
SetDlgItemText(hDlg,IDC_LAN,GS(INI_CURRENT_LANG));
|
|
|
|
sprintf(String,"%s: %s",GS(INI_AUTHOR),GS(LANGUAGE_AUTHOR));
|
|
|
|
SetDlgItemText(hDlg,IDC_LAN_AUTHOR,String);
|
|
|
|
sprintf(String,"%s: %s",GS(INI_VERSION),GS(LANGUAGE_VERSION));
|
|
|
|
SetDlgItemText(hDlg,IDC_LAN_VERSION,String);
|
|
|
|
sprintf(String,"%s: %s",GS(INI_DATE),GS(LANGUAGE_DATE));
|
|
|
|
SetDlgItemText(hDlg,IDC_LAN_DATE,String);
|
|
|
|
if (strlen(GS(LANGUAGE_NAME)) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_LAN),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_LAN_AUTHOR),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_LAN_VERSION),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_LAN_DATE),FALSE);
|
|
|
|
}
|
2013-03-31 16:10:54 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
//RDB
|
2012-11-17 01:02:04 +00:00
|
|
|
stdstr IniFile = g_Settings->LoadString(SupportFile_RomDatabase).c_str();
|
2008-09-18 03:15:49 +00:00
|
|
|
SetDlgItemText(hDlg,IDC_RDB,GS(INI_CURRENT_RDB));
|
|
|
|
GetPrivateProfileString("Meta","Author","",String,sizeof(String),IniFile.c_str());
|
|
|
|
if (strlen(String) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB_AUTHOR),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB_VERSION),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB_DATE),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB_HOME),FALSE);
|
|
|
|
}
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_AUTHOR),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDB_AUTHOR,String2);
|
|
|
|
GetPrivateProfileString("Meta","Version","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_VERSION),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDB_VERSION,String2);
|
|
|
|
GetPrivateProfileString("Meta","Date","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_DATE),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDB_DATE,String2);
|
|
|
|
GetPrivateProfileString("Meta","Homepage","",RDBHomePage,sizeof(RDBHomePage),IniFile.c_str());
|
|
|
|
SetDlgItemText(hDlg,IDC_RDB_HOME,GS(INI_HOMEPAGE));
|
|
|
|
if (strlen(RDBHomePage) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDB_HOME),FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Cheat
|
|
|
|
SetDlgItemText(hDlg,IDC_CHT,GS(INI_CURRENT_CHT));
|
2012-11-17 01:02:04 +00:00
|
|
|
IniFile = g_Settings->LoadString(SupportFile_Cheats).c_str();
|
2008-09-18 03:15:49 +00:00
|
|
|
GetPrivateProfileString("Meta","Author","",String,sizeof(String),IniFile.c_str());
|
|
|
|
if (strlen(String) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT_AUTHOR),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT_VERSION),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT_DATE),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT_HOME),FALSE);
|
|
|
|
}
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_AUTHOR),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_CHT_AUTHOR,String2);
|
|
|
|
GetPrivateProfileString("Meta","Version","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_VERSION),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_CHT_VERSION,String2);
|
|
|
|
GetPrivateProfileString("Meta","Date","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_DATE),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_CHT_DATE,String2);
|
|
|
|
GetPrivateProfileString("Meta","Homepage","",CHTHomePage,sizeof(CHTHomePage),IniFile.c_str());
|
|
|
|
SetDlgItemText(hDlg,IDC_CHT_HOME,GS(INI_HOMEPAGE));
|
|
|
|
if (strlen(CHTHomePage) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_CHT_HOME),FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Extended Info
|
|
|
|
SetDlgItemText(hDlg,IDC_RDX,GS(INI_CURRENT_RDX));
|
2012-11-17 01:02:04 +00:00
|
|
|
IniFile = g_Settings->LoadString(SupportFile_ExtInfo).c_str();;
|
2008-09-18 03:15:49 +00:00
|
|
|
GetPrivateProfileString("Meta","Author","",String,sizeof(String),IniFile.c_str());
|
|
|
|
if (strlen(String) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX_AUTHOR),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX_VERSION),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX_DATE),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX_HOME),FALSE);
|
|
|
|
}
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_AUTHOR),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDX_AUTHOR,String2);
|
|
|
|
GetPrivateProfileString("Meta","Version","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_VERSION),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDX_VERSION,String2);
|
|
|
|
GetPrivateProfileString("Meta","Date","",String,sizeof(String),IniFile.c_str());
|
|
|
|
sprintf(String2,"%s: %s",GS(INI_DATE),String);
|
|
|
|
SetDlgItemText(hDlg,IDC_RDX_DATE,String2);
|
|
|
|
GetPrivateProfileString("Meta","Homepage","",RDXHomePage,sizeof(CHTHomePage),IniFile.c_str());
|
|
|
|
SetDlgItemText(hDlg,IDC_RDX_HOME,GS(INI_HOMEPAGE));
|
|
|
|
if (strlen(RDXHomePage) == 0) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg,IDC_RDX_HOME),FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDC_RDB_HOME: ShellExecute(NULL,"open",RDBHomePage,NULL,NULL,SW_SHOWNORMAL); break;
|
|
|
|
case IDC_CHT_HOME: ShellExecute(NULL,"open",CHTHomePage,NULL,NULL,SW_SHOWNORMAL); break;
|
|
|
|
case IDC_RDX_HOME: ShellExecute(NULL,"open",RDXHomePage,NULL,NULL,SW_SHOWNORMAL); break;
|
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog((HWND)WndHandle,0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-02-12 10:58:28 +00:00
|
|
|
bool CMainGui::ResetPlugins (CPlugins * plugins, CN64System * System)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
RESET_PLUGIN info;
|
|
|
|
info.system = System;
|
|
|
|
info.plugins = plugins;
|
|
|
|
info.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
|
2013-01-03 08:51:00 +00:00
|
|
|
bool bRes = true;
|
2015-02-12 10:58:28 +00:00
|
|
|
if (info.hEvent)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
PostMessage((HWND)m_hMainWindow,WM_RESET_PLUGIN,(WPARAM)&bRes,(LPARAM)&info);
|
|
|
|
#ifdef _DEBUG
|
|
|
|
DWORD dwRes = WaitForSingleObject(info.hEvent,INFINITE);
|
|
|
|
#else
|
|
|
|
DWORD dwRes = WaitForSingleObject(info.hEvent,5000);
|
|
|
|
#endif
|
|
|
|
dwRes = dwRes;
|
|
|
|
CloseHandle(info.hEvent);
|
2013-01-03 08:51:00 +00:00
|
|
|
} else {
|
|
|
|
WriteTrace(TraceError,__FUNCTION__ ": Failed to create event");
|
|
|
|
bRes = false;
|
|
|
|
}
|
2015-02-12 10:58:28 +00:00
|
|
|
return bRes;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::BringToTop (void) {
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
SetForegroundWindow((HWND)m_hMainWindow);
|
|
|
|
SetFocus(GetDesktopWindow());
|
|
|
|
Sleep(100);
|
|
|
|
SetFocus((HWND)m_hMainWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::MakeWindowOnTop (bool OnTop) {
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
SetWindowPos((HWND)m_hMainWindow,OnTop ? HWND_TOPMOST : HWND_NOTOPMOST,0,0,0,0,
|
|
|
|
SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::Caption (LPCSTR Caption) {
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
SetWindowText((HWND)m_hMainWindow,Caption);
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
void CMainGui::Create (const char * WindowTitle)
|
|
|
|
{
|
2015-01-27 05:07:44 +00:00
|
|
|
m_hMainWindow = (HWND)CreateWindow ("Project64 2.0", WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN |
|
2008-09-18 03:15:49 +00:00
|
|
|
WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX,5,5,640,480,
|
|
|
|
NULL,NULL,GetModuleHandle(NULL),this );
|
2015-02-13 19:40:25 +00:00
|
|
|
m_Created = m_hMainWindow != NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::CreateStatusBar (void) {
|
2015-01-27 05:07:44 +00:00
|
|
|
m_hStatusWnd = (HWND)CreateStatusWindow( WS_CHILD | WS_VISIBLE, "", (HWND)m_hMainWindow, StatusBarID );
|
2008-09-18 03:15:49 +00:00
|
|
|
SendMessage( (HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)"" );
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMainGui::ProcessAllMessages (void) {
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (GetMessage(&msg,NULL,0,0)) {
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem && g_BaseSystem->IsDialogMsg(&msg))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//if (IsDialogMessage( hManageWindow,&msg)) { continue; }
|
|
|
|
if (m_Menu->ProcessAccelerator(m_hMainWindow,&msg)) { continue; }
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
return msg.wParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CMainGui::ProcessGuiMessages (void) {
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
|
|
|
|
{
|
|
|
|
if (msg.message == WM_QUIT) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
|
|
|
|
if (m_Menu->ProcessAccelerator(m_hMainWindow,&msg)) { continue; }
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:20:53 +00:00
|
|
|
void CMainGui::Resize (DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) {
|
2008-09-18 03:15:49 +00:00
|
|
|
RECT clrect, swrect;
|
|
|
|
GetClientRect( (HWND)m_hMainWindow, &clrect );
|
|
|
|
GetClientRect( (HWND)m_hStatusWnd, &swrect );
|
|
|
|
|
|
|
|
int Parts[2];
|
|
|
|
Parts[0] = (nWidth - (int)( clrect.right * 0.25 ));
|
|
|
|
Parts[1] = nWidth;
|
|
|
|
|
|
|
|
SendMessage( (HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0] );
|
|
|
|
MoveWindow ( (HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom,nWidth, nHeight, TRUE );
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
void CMainGui::Show (bool Visible)
|
|
|
|
{
|
|
|
|
m_MakingVisible = true;
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
CGuard Guard(m_CS);
|
2015-02-13 19:40:25 +00:00
|
|
|
if (m_hMainWindow)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
ShowWindow((HWND)m_hMainWindow,Visible?SW_SHOW:SW_HIDE);
|
2015-02-13 19:40:25 +00:00
|
|
|
if (Visible && RomBrowserVisible())
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
RomBrowserToTop();
|
|
|
|
}
|
|
|
|
}
|
2015-02-13 19:40:25 +00:00
|
|
|
|
|
|
|
m_MakingVisible = false;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::EnterLogOptions (void)
|
|
|
|
{
|
|
|
|
::EnterLogOptions((HWND)m_hMainWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMainGui::Height (void) {
|
|
|
|
if (!m_hMainWindow) { return 0; }
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect((HWND)m_hMainWindow,&rect);
|
|
|
|
return rect.bottom - rect.top;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
int CMainGui::Width (void)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
if (!m_hMainWindow) { return 0; }
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect((HWND)m_hMainWindow,&rect);
|
|
|
|
return rect.right - rect.left;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
void CMainGui::SetPos (int X, int Y)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
SetWindowPos((HWND)m_hMainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE);
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
void CMainGui::SetWindowMenu (CBaseMenu * Menu)
|
|
|
|
{
|
|
|
|
m_AttachingMenu = true;
|
2010-06-29 02:11:22 +00:00
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
HMENU hMenu = NULL;
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
m_Menu = Menu;
|
|
|
|
hMenu = (HMENU)Menu->GetHandle();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hMenu)
|
|
|
|
{
|
|
|
|
SetMenu((HWND)m_hMainWindow,hMenu);
|
|
|
|
}
|
2015-02-13 19:40:25 +00:00
|
|
|
|
|
|
|
m_AttachingMenu = false;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 21:22:06 +00:00
|
|
|
void CMainGui::RefreshMenu (void)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
if (!m_Menu) { return; }
|
|
|
|
m_Menu->ResetMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SetStatusText (int Panel,const char * Text) {
|
|
|
|
static char Message[2][500];
|
|
|
|
if (Panel >= 2)
|
|
|
|
{
|
|
|
|
Notify().BreakPoint(__FILE__,__LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
char * Msg = Message[Panel];
|
|
|
|
|
|
|
|
memset(Msg,0,sizeof(Message[0]));
|
|
|
|
_snprintf(Msg,sizeof(Message[0]),"%s",Text);
|
|
|
|
Msg[sizeof(Message[0]) - 1] = 0;
|
2013-01-03 08:51:00 +00:00
|
|
|
if (GetCurrentThreadId() == m_ThreadId)
|
|
|
|
{
|
|
|
|
SendMessage( (HWND)m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg );
|
|
|
|
} else {
|
|
|
|
PostMessage( (HWND)m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg );
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::ShowStatusBar ( bool ShowBar )
|
|
|
|
{
|
|
|
|
ShowWindow((HWND)m_hStatusWnd,ShowBar ? SW_SHOW : SW_HIDE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMainGui::SaveWindowLoc ( void )
|
|
|
|
{
|
2015-02-13 19:40:25 +00:00
|
|
|
bool flush = false;
|
2008-09-18 03:15:49 +00:00
|
|
|
if (m_SaveMainWindowPos)
|
|
|
|
{
|
|
|
|
m_SaveMainWindowPos = false;
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveDword(UserInterface_MainWindowTop,m_SaveMainWindowTop);
|
|
|
|
g_Settings->SaveDword(UserInterface_MainWindowLeft,m_SaveMainWindowLeft);
|
2015-02-13 19:40:25 +00:00
|
|
|
flush = true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SaveRomBrowserPos)
|
|
|
|
{
|
|
|
|
m_SaveRomBrowserPos = false;
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveDword(RomBrowser_Top,m_SaveRomBrowserTop);
|
|
|
|
g_Settings->SaveDword(RomBrowser_Left,m_SaveRomBrowserLeft);
|
2015-02-13 19:40:25 +00:00
|
|
|
flush = true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
if (flush)
|
|
|
|
{
|
|
|
|
CSettingTypeApplication::Flush();
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) {
|
2008-09-18 03:15:49 +00:00
|
|
|
switch (uMsg) {
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
//record class for future usage
|
|
|
|
LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
|
|
|
|
CMainGui * _this = (CMainGui *)lpcs->lpCreateParams;
|
|
|
|
SetProp((HWND)hWnd,"Class",_this);
|
|
|
|
|
2013-03-22 05:47:20 +00:00
|
|
|
#if defined(BETA_RELEASE) || defined(VALIDATE_BIN_LOCAL)
|
2008-09-18 03:15:49 +00:00
|
|
|
TestValidBinary();
|
|
|
|
SetTimer((HWND)hWnd,0,10000,NULL);
|
|
|
|
#endif
|
|
|
|
_this->m_hMainWindow = hWnd;
|
|
|
|
_this->CreateStatusBar();
|
|
|
|
|
|
|
|
//Move the Main window to the location last executed from or center the window
|
|
|
|
int X = (GetSystemMetrics( SM_CXSCREEN ) - _this->Width()) / 2;
|
|
|
|
int Y = (GetSystemMetrics( SM_CYSCREEN ) - _this->Height()) / 2;
|
2015-02-15 07:10:25 +00:00
|
|
|
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->LoadDword(UserInterface_MainWindowTop,(DWORD &)Y);
|
|
|
|
g_Settings->LoadDword(UserInterface_MainWindowLeft,(DWORD &)X);
|
2015-02-15 07:10:25 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
_this->SetPos(X,Y);
|
|
|
|
|
|
|
|
_this->ChangeWinSize(640,480);
|
|
|
|
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
if (_this->m_hacked)
|
|
|
|
{
|
|
|
|
MessageBox(NULL,"Exe has been corrupted","Stopping",MB_OK|MB_ICONEXCLAMATION);
|
|
|
|
}
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
switch (wParam) {
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
case SC_MONITORPOWER:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this &&
|
2008-11-14 20:51:06 +00:00
|
|
|
_this->bCPURunning() &&
|
2012-11-17 01:02:04 +00:00
|
|
|
!g_Settings->LoadBool(GameRunning_CPU_Paused) &&
|
|
|
|
g_Settings->LoadDword(Setting_DisableScrSaver))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SC_MAXIMIZE:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this) {
|
|
|
|
if (_this->RomBrowserVisible()) {
|
|
|
|
_this->RomBrowserMaximize(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam);
|
|
|
|
break;
|
|
|
|
case WM_MOVE:
|
|
|
|
{
|
2015-02-13 19:40:25 +00:00
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
2010-05-22 04:47:15 +00:00
|
|
|
|
2015-02-13 19:40:25 +00:00
|
|
|
if (!_this->m_bMainWindow ||
|
|
|
|
!_this->m_Created ||
|
|
|
|
_this->m_AttachingMenu ||
|
|
|
|
_this->m_MakingVisible ||
|
|
|
|
IsIconic((HWND)hWnd) ||
|
|
|
|
_this->ShowingRomBrowser())
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2015-02-13 19:40:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsZoomed((HWND)hWnd))
|
|
|
|
{
|
|
|
|
if (_this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
// save that browser is maximized
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2015-02-13 19:40:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//get the current position of the window
|
|
|
|
RECT WinRect;
|
|
|
|
GetWindowRect((HWND)hWnd, &WinRect );
|
|
|
|
|
|
|
|
//save the location of the window
|
|
|
|
if (_this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
_this->m_SaveRomBrowserPos = true;
|
|
|
|
_this->m_SaveRomBrowserTop = WinRect.top;
|
|
|
|
_this->m_SaveRomBrowserLeft = WinRect.left;
|
|
|
|
} else {
|
|
|
|
_this->m_SaveMainWindowPos = true;
|
|
|
|
_this->m_SaveMainWindowTop = WinRect.top;
|
|
|
|
_this->m_SaveMainWindowLeft = WinRect.left;
|
|
|
|
}
|
|
|
|
KillTimer(hWnd,Timer_SetWindowPos);
|
|
|
|
SetTimer(hWnd,Timer_SetWindowPos,1000,NULL);
|
|
|
|
}
|
|
|
|
if (CGuiSettings::bCPURunning() && g_BaseSystem)
|
|
|
|
{
|
|
|
|
if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Starting");
|
|
|
|
g_Plugins->Gfx()->MoveScreen((int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam));
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_TIMER:
|
2015-02-13 19:40:25 +00:00
|
|
|
if (wParam == Timer_SetWindowPos)
|
|
|
|
{
|
|
|
|
KillTimer(hWnd,Timer_SetWindowPos);
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
_this->SaveWindowLoc();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
static DWORD CallCount = 0;
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(Beta_IsValidExe))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
if (CallCount == 0)
|
|
|
|
{
|
|
|
|
CallCount = 1;
|
|
|
|
PostMessage((HWND)hWnd,_this->m_InvalidExeMsg,0,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CallCount > 0)
|
|
|
|
{
|
|
|
|
if (CallCount == 9)
|
|
|
|
{
|
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
CallCount++;
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2015-02-13 19:40:25 +00:00
|
|
|
break;
|
2008-09-18 03:15:49 +00:00
|
|
|
case WM_SIZE:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this) { _this->Resize(wParam,LOWORD(lParam), HIWORD(lParam)); }
|
|
|
|
if (_this)
|
|
|
|
{
|
|
|
|
if (wParam == SIZE_MAXIMIZED)
|
|
|
|
{
|
|
|
|
if (_this->RomBrowserVisible()) {
|
|
|
|
_this->RomBrowserMaximize(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_this->ResizeRomList(LOWORD(lParam), HIWORD(lParam));
|
|
|
|
}
|
|
|
|
if (_this) {
|
|
|
|
if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) {
|
|
|
|
_this->RomBrowserMaximize(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this) {
|
|
|
|
if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam,lParam)) {
|
|
|
|
return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this) {
|
|
|
|
if (!_this->RomListDrawItem(wParam,lParam)) {
|
|
|
|
return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
// CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
// CN64System * System = _this->m_System;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
// if (bCPURunning() && Settings->Load(CPU_Paused)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
// CPlugins * Plugins = System->Plugins();
|
|
|
|
// if (Plugins->Gfx()->DrawScreen) {
|
|
|
|
// Plugins->Gfx()->DrawScreen();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
ValidateRect((HWND)hWnd,NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KEYUP:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
if (g_Plugins && g_Plugins->Control()->WM_KeyUp) {
|
|
|
|
g_Plugins->Control()->WM_KeyUp(wParam, lParam);
|
2010-05-22 04:47:15 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
if (g_Plugins && g_Plugins->Control()->WM_KeyDown)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Control()->WM_KeyDown(wParam, lParam);
|
2010-05-22 04:47:15 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->ExternalEvent( SysEvent_ResumeCPU_AppGainedFocus );
|
2010-05-22 04:47:15 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KILLFOCUS:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this->RomBrowserVisible())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
|
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->ExternalEvent( SysEvent_PauseCPU_AppLostFocus );
|
2010-05-22 04:47:15 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_ACTIVATEAPP:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
DWORD fActive = (BOOL) wParam;
|
|
|
|
|
|
|
|
if (fActive && _this->RomBrowserVisible()) {
|
|
|
|
PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0);
|
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow && bCPURunning())
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen))
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->WindowMode();
|
2012-11-17 01:09:19 +00:00
|
|
|
if (bAutoSleep() && g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
|
|
|
//System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-22 05:53:39 +00:00
|
|
|
if (bAutoSleep() || fActive)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem)
|
2010-05-22 04:47:15 +00:00
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive );
|
2010-05-22 04:47:15 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2010-05-22 04:47:15 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_HIDE_CUROSR:
|
|
|
|
if (!wParam) {
|
|
|
|
while (ShowCursor(FALSE) >= 0) { Sleep(0); }
|
|
|
|
} else {
|
|
|
|
while (ShowCursor(TRUE) < 0) { Sleep(0); }
|
|
|
|
}
|
|
|
|
break;
|
2012-11-28 21:22:06 +00:00
|
|
|
case WM_MAKE_FOCUS:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
_this->BringToTop();
|
|
|
|
}
|
|
|
|
break;
|
2008-09-18 03:15:49 +00:00
|
|
|
case WM_BORWSER_TOP:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
_this->RomBrowserToTop();
|
|
|
|
}
|
|
|
|
break;
|
2015-02-12 10:58:28 +00:00
|
|
|
case WM_RESET_PLUGIN:
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
RESET_PLUGIN * info = (RESET_PLUGIN *)lParam;
|
2013-01-03 08:51:00 +00:00
|
|
|
|
2015-02-12 10:58:28 +00:00
|
|
|
info->res = info->plugins->Reset(info->system);
|
|
|
|
SetEvent(info->hEvent);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2015-02-12 10:58:28 +00:00
|
|
|
break;
|
2008-09-18 03:15:49 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this == NULL) { break; }
|
|
|
|
|
|
|
|
switch (LOWORD(wParam)) {
|
2012-11-17 01:09:19 +00:00
|
|
|
case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break;
|
2010-05-22 04:47:15 +00:00
|
|
|
case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break;
|
2008-09-18 03:15:49 +00:00
|
|
|
case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break;
|
|
|
|
case ID_POPUPMENU_ROMINFORMATION:
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
RomInformation Info(_this->CurrentedSelectedRom());
|
2008-09-18 03:15:49 +00:00
|
|
|
Info.DisplayInformation(hWnd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_EDITSETTINGS:
|
|
|
|
case ID_POPUPMENU_EDITCHEATS:
|
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
CN64Rom Rom;
|
2008-09-18 03:15:49 +00:00
|
|
|
Rom.LoadN64Image(_this->CurrentedSelectedRom(),true);
|
|
|
|
Rom.SaveRomSettingID();
|
2012-11-17 01:02:04 +00:00
|
|
|
/*if (g_Settings->LoadString(ROM_MD5).length() == 0) {
|
2008-09-18 03:15:49 +00:00
|
|
|
Rom.LoadN64Image(_this->CurrentedSelectedRom(),false);
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(ROM_MD5,Rom.GetRomMD5().c_str());
|
|
|
|
g_Settings->SaveString(ROM_InternalName,Rom.GetRomName().c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
|
|
|
|
{
|
|
|
|
CSettingConfig SettingConfig(true);
|
|
|
|
SettingConfig.Display(hWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) {
|
2010-05-22 04:47:15 +00:00
|
|
|
CCheats RomCheats(&Rom);
|
2008-09-18 03:15:49 +00:00
|
|
|
RomCheats.SelectCheats(hWnd,true);
|
|
|
|
}
|
|
|
|
|
2012-11-17 02:24:42 +00:00
|
|
|
if (g_Rom) {
|
|
|
|
g_Rom->SaveRomSettingID();
|
2008-09-18 03:15:49 +00:00
|
|
|
} else {
|
2008-11-14 20:51:06 +00:00
|
|
|
Rom.ClearRomSettingID();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (_this->m_Menu) {
|
|
|
|
if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100 ) {
|
2012-11-17 02:20:21 +00:00
|
|
|
if (g_Plugins->RSP())
|
2010-09-22 21:43:42 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
} else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200 ) {
|
2012-11-17 02:20:21 +00:00
|
|
|
if (g_Plugins->Gfx())
|
2010-09-22 21:43:42 +00:00
|
|
|
{
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Starting");
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
} else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300 ) {
|
2012-11-17 02:20:21 +00:00
|
|
|
if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2010-05-22 04:47:15 +00:00
|
|
|
CN64Rom Rom;
|
2008-09-18 03:15:49 +00:00
|
|
|
if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Rom.SaveRomSettingID();
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->DisplayMessage(0,"");
|
2008-09-18 03:15:49 +00:00
|
|
|
BYTE * RomHeader = Rom.GetRomAddress();
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": OnRomBrowserMenuItem - Starting");
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam),hWnd,RomHeader);
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": OnRomBrowserMenuItem - Done");
|
2012-11-17 02:24:42 +00:00
|
|
|
if (g_Rom) {
|
|
|
|
g_Rom->SaveRomSettingID();
|
2008-09-18 03:15:49 +00:00
|
|
|
} else {
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Game_IniKey,"");
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (_this->m_Menu->ProcessMessage(hWnd,HIWORD(wParam), LOWORD(wParam))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_DESTROY:
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - start");
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->WindowMode();
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
_this->m_hMainWindow = NULL;
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 1");
|
2010-05-22 04:47:15 +00:00
|
|
|
if (_this->m_bMainWindow)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
_this->SaveRomListColoumnInfo();
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 2");
|
2008-11-14 20:51:06 +00:00
|
|
|
_this->SaveWindowLoc();
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 3");
|
2008-09-18 03:15:49 +00:00
|
|
|
RemoveProp((HWND)hWnd,"Class");
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 4");
|
2008-09-18 03:15:49 +00:00
|
|
|
PostQuitMessage(0);
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
|
|
|
|
if (_this)
|
|
|
|
{
|
|
|
|
if (uMsg == _this->m_InvalidExeMsg)
|
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->CloseCpu();
|
2008-09-18 03:15:49 +00:00
|
|
|
MessageBox((HWND)hWnd,GS(MSG_INVALID_EXE),GS(MSG_INVALID_EXE_TITLE),MB_OK|MB_ICONERROR);
|
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
WNDPROC pfnWndAboutBoxCancelProc = NULL;
|
|
|
|
HBITMAP hCloseButton = NULL;
|
|
|
|
|
|
|
|
DWORD CALLBACK AboutBoxCancelProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
|
|
|
if (BeginPaint(hWnd,&ps))
|
|
|
|
{
|
|
|
|
if (hCloseButton)
|
|
|
|
{
|
|
|
|
RECT rcClient;
|
|
|
|
GetClientRect(hWnd, &rcClient);
|
|
|
|
|
|
|
|
BITMAP bmTL1;
|
|
|
|
GetObject(hCloseButton, sizeof(BITMAP), &bmTL1);
|
|
|
|
HDC memdc = CreateCompatibleDC(ps.hdc);
|
|
|
|
HGDIOBJ save = SelectObject(memdc, hCloseButton);
|
|
|
|
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
|
|
|
|
SelectObject(memdc, save);
|
|
|
|
DeleteDC(memdc);
|
|
|
|
}
|
|
|
|
EndPaint(hWnd,&ps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallWindowProc(pfnWndAboutBoxCancelProc, hWnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
LPSTR ValidateDecryptString (LPSTR String, int Len);
|
|
|
|
LPSTR ValidateEncryptString (LPSTR String, int Len);
|
|
|
|
|
|
|
|
LPSTR ValidateDecryptString2 (LPSTR String, int Len)
|
|
|
|
{
|
|
|
|
BYTE PreviousChar = 0xAA;
|
|
|
|
for (int x = 0; x < Len; x++)
|
|
|
|
{
|
2012-12-19 11:28:11 +00:00
|
|
|
String[x] ^= (PreviousChar + x) & 0xFF;
|
2008-09-18 03:15:49 +00:00
|
|
|
PreviousChar = String[x];
|
|
|
|
}
|
|
|
|
return String;
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:20:53 +00:00
|
|
|
DWORD CALLBACK AboutUserProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD /*lParam*/)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
static char UserInfo[] = "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh";
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
char WindowTitleLabel[] = "\xff\x26\x16\x17\x52\x69\x27\x08\x09"; // "User Info";
|
|
|
|
ValidateDecryptString(WindowTitleLabel,sizeof(WindowTitleLabel) - 1);
|
|
|
|
SetWindowText(hWnd,WindowTitleLabel);
|
|
|
|
|
|
|
|
char UserIdLabel[] = "\xff\x26\x16\x17\x52\x69\x0d\x7e"; // "User ID:";
|
|
|
|
ValidateDecryptString(UserIdLabel,sizeof(UserIdLabel) - 1);
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_LABEL1),UserIdLabel);
|
|
|
|
|
|
|
|
char UserNameLabel[] = "\xff\x26\x16\x17\x52\x6e\x2f\x0c\x08\x5f"; // "User Name:";
|
|
|
|
ValidateDecryptString(UserNameLabel,sizeof(UserNameLabel) - 1);
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_LABEL2),UserNameLabel);
|
|
|
|
|
|
|
|
char UserEmailLabel[] = "\xef\x28\x0c\x08\x05\x56"; // "Email:";
|
|
|
|
ValidateDecryptString(UserEmailLabel,sizeof(UserEmailLabel) - 1);
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_LABEL3),UserEmailLabel);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BYTE UserID[10];
|
|
|
|
BYTE UserName[80];
|
|
|
|
BYTE Email[80];
|
|
|
|
} USER_INFO;
|
|
|
|
|
|
|
|
USER_INFO * info = (USER_INFO *)UserInfo;
|
|
|
|
ValidateDecryptString2(UserInfo,sizeof(UserInfo) - 1);
|
|
|
|
info->UserID[sizeof(info->UserID) - 1] = 0;
|
|
|
|
info->UserName[sizeof(info->UserName) - 1] = 0;
|
|
|
|
info->Email[sizeof(info->Email) - 1] = 0;
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_INFO1),(char *)info->UserID);
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_INFO2),(char *)info->UserName);
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_INFO3),(char *)info->Email);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hWnd,0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
|
|
|
|
{
|
|
|
|
static HBITMAP hbmpBackgroundTop = NULL;
|
|
|
|
static HBITMAP hbmpBackgroundBottom = NULL;
|
|
|
|
static HBITMAP hbmpBackgroundMiddle = NULL;
|
|
|
|
static HFONT hPageHeadingFont = NULL;
|
|
|
|
static HFONT hTextFont = NULL;
|
|
|
|
static HFONT hAuthorFont = NULL;
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
enum { ROUND_EDGE = 15 };
|
|
|
|
|
|
|
|
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
|
|
|
|
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
|
|
|
|
SetWindowLong(hWnd, GWL_STYLE, dwStyle);
|
|
|
|
|
|
|
|
// Use the size of the image
|
|
|
|
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
|
|
|
|
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
|
|
|
|
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
|
|
|
|
|
|
|
|
BITMAP bmTL;
|
|
|
|
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
|
|
|
|
|
|
|
|
hCloseButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_CLOSE_NORMAL));
|
|
|
|
pfnWndAboutBoxCancelProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hWnd,IDCANCEL), GWLP_WNDPROC);
|
|
|
|
::SetWindowLongPtr(GetDlgItem(hWnd,IDCANCEL), GWLP_WNDPROC,(LONG_PTR)AboutBoxCancelProc);
|
|
|
|
|
|
|
|
|
|
|
|
if (hbmpBackgroundTop)
|
|
|
|
{
|
|
|
|
// int iHeight = bmTL.bmHeight;
|
|
|
|
int iWidth = bmTL.bmWidth;
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect(hWnd, &rect);
|
|
|
|
rect.left -= rect.left;
|
|
|
|
rect.bottom -= rect.top;
|
|
|
|
rect.top -= rect.top;
|
|
|
|
|
|
|
|
// Tweaked
|
|
|
|
HRGN hWindowRegion= CreateRoundRectRgn
|
|
|
|
(
|
|
|
|
rect.left,
|
|
|
|
rect.top,
|
|
|
|
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
|
|
|
|
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
|
|
|
|
ROUND_EDGE,
|
|
|
|
ROUND_EDGE
|
|
|
|
);
|
|
|
|
|
|
|
|
if (hWindowRegion)
|
|
|
|
{
|
|
|
|
SetWindowRgn(hWnd, hWindowRegion, TRUE);
|
|
|
|
DeleteObject(hWindowRegion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hTextFont = ::CreateFont
|
|
|
|
(
|
|
|
|
18,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
FW_NORMAL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
DEFAULT_CHARSET,
|
|
|
|
OUT_DEFAULT_PRECIS,
|
|
|
|
CLIP_DEFAULT_PRECIS,
|
|
|
|
PROOF_QUALITY,
|
|
|
|
DEFAULT_PITCH|FF_DONTCARE,
|
|
|
|
_T("Arial")
|
|
|
|
);
|
|
|
|
|
|
|
|
hAuthorFont = ::CreateFont
|
|
|
|
(
|
|
|
|
18,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
FW_BOLD,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
DEFAULT_CHARSET,
|
|
|
|
OUT_DEFAULT_PRECIS,
|
|
|
|
CLIP_DEFAULT_PRECIS,
|
|
|
|
PROOF_QUALITY,
|
|
|
|
DEFAULT_PITCH|FF_DONTCARE,
|
|
|
|
_T("Arial")
|
|
|
|
);
|
|
|
|
|
|
|
|
hPageHeadingFont = ::CreateFont
|
|
|
|
(
|
|
|
|
24,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
FW_BOLD,
|
|
|
|
0,
|
|
|
|
FALSE, //Show underlined?
|
|
|
|
0,
|
|
|
|
DEFAULT_CHARSET,
|
|
|
|
OUT_DEFAULT_PRECIS,
|
|
|
|
CLIP_DEFAULT_PRECIS,
|
|
|
|
PROOF_QUALITY,
|
|
|
|
DEFAULT_PITCH|FF_DONTCARE,
|
|
|
|
_T("Arial Bold")
|
|
|
|
);
|
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd,IDC_VERSION,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_TEAM,WM_SETFONT,(WPARAM)hPageHeadingFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_THANKS,WM_SETFONT,(WPARAM)hPageHeadingFont,TRUE);
|
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd,IDC_ZILMAR,WM_SETFONT,(WPARAM)hAuthorFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_JABO,WM_SETFONT,(WPARAM)hAuthorFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_SMIFF,WM_SETFONT,(WPARAM)hAuthorFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_GENT,WM_SETFONT,(WPARAM)hAuthorFont,TRUE);
|
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd,IDC_ZILMAR_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_JABO_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_SMIFF_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
SendDlgItemMessage(hWnd,IDC_GENT_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
|
|
|
|
SendDlgItemMessage(hWnd,IDC_THANK_LIST,WM_SETFONT,(WPARAM)hTextFont,TRUE);
|
|
|
|
|
|
|
|
//SetCapture(hWnd);
|
|
|
|
stdstr StrVersion(VersionInfo(VERSION_PRODUCT_VERSION));
|
|
|
|
stdstr_f VersionDisplay("Version: %s",StrVersion.c_str());
|
|
|
|
SetWindowText(GetDlgItem(hWnd,IDC_VERSION),VersionDisplay.c_str());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_NCHITTEST:
|
|
|
|
{
|
|
|
|
int xPos = LOWORD(lParam);
|
|
|
|
int yPos = HIWORD(lParam);
|
|
|
|
RECT client, a;
|
|
|
|
GetClientRect(hWnd,&a);
|
|
|
|
GetClientRect(hWnd,&client);
|
|
|
|
ClientToScreen(hWnd,(LPPOINT)&client);
|
|
|
|
client.right += client.left;
|
|
|
|
client.bottom += client.top;
|
|
|
|
|
|
|
|
|
|
|
|
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
|
|
|
|
|
|
|
|
LRESULT lResult = HTCLIENT;
|
|
|
|
|
|
|
|
//check caption
|
|
|
|
if (xPos <= client.right && xPos >= client.left &&
|
|
|
|
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
|
|
|
|
{
|
|
|
|
lResult = HTCAPTION;
|
|
|
|
}
|
|
|
|
SetWindowLong(hWnd, DWL_MSGRESULT, lResult);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
{
|
|
|
|
HDC hdcStatic = (HDC)wParam;
|
|
|
|
SetTextColor(hdcStatic, RGB(0, 0, 0));
|
|
|
|
SetBkMode(hdcStatic, TRANSPARENT);
|
|
|
|
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
|
|
|
if (BeginPaint(hWnd,&ps))
|
|
|
|
{
|
|
|
|
RECT rcClient;
|
|
|
|
GetClientRect(hWnd, &rcClient);
|
|
|
|
|
|
|
|
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
|
|
|
|
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
|
|
|
|
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
|
|
|
|
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
|
|
|
|
|
|
|
|
HDC memdc = CreateCompatibleDC(ps.hdc);
|
|
|
|
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
|
|
|
|
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
|
|
|
|
SelectObject(memdc, save);
|
|
|
|
DeleteDC(memdc);
|
|
|
|
|
|
|
|
|
|
|
|
memdc = CreateCompatibleDC(ps.hdc);
|
|
|
|
save = SelectObject(memdc, hbmpBackgroundMiddle);
|
|
|
|
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
|
|
|
|
{
|
|
|
|
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
|
|
|
|
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
|
|
|
|
}
|
|
|
|
SelectObject(memdc, save);
|
|
|
|
DeleteDC(memdc);
|
|
|
|
|
|
|
|
BITMAP ;
|
|
|
|
memdc = CreateCompatibleDC(ps.hdc);
|
|
|
|
save = SelectObject(memdc, hbmpBackgroundBottom);
|
|
|
|
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
|
|
|
|
SelectObject(memdc, save);
|
|
|
|
DeleteDC(memdc);
|
|
|
|
|
|
|
|
BITMAP ;
|
|
|
|
|
|
|
|
EndPaint(hWnd,&ps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
2013-03-22 05:47:20 +00:00
|
|
|
#ifdef BETA_RELEASE
|
2008-09-18 03:15:49 +00:00
|
|
|
case IDC_VERSION:
|
|
|
|
if ((GetKeyState(VK_CONTROL) & 0x80))
|
|
|
|
{
|
|
|
|
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_UserInfo), (HWND)hWnd, (DLGPROC)AboutUserProc);
|
|
|
|
}
|
|
|
|
break;
|
2013-03-22 05:47:20 +00:00
|
|
|
#endif
|
2008-09-18 03:15:49 +00:00
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
|
|
|
if (hbmpBackgroundTop)
|
|
|
|
{
|
|
|
|
DeleteObject(hbmpBackgroundTop);
|
|
|
|
}
|
|
|
|
if (hbmpBackgroundBottom)
|
|
|
|
{
|
|
|
|
DeleteObject(hbmpBackgroundBottom);
|
|
|
|
}
|
|
|
|
if (hbmpBackgroundMiddle)
|
|
|
|
{
|
|
|
|
DeleteObject(hbmpBackgroundMiddle);
|
|
|
|
}
|
|
|
|
if (hTextFont)
|
|
|
|
::DeleteObject(hTextFont);
|
|
|
|
if (hPageHeadingFont)
|
|
|
|
::DeleteObject(hPageHeadingFont);
|
|
|
|
if (hAuthorFont)
|
|
|
|
::DeleteObject(hAuthorFont);
|
|
|
|
|
|
|
|
|
|
|
|
//ReleaseCapture();
|
|
|
|
EndDialog(hWnd,0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|