PropertySheet: only allow 1 "afterclose" msg, which is done when the last page (that was accessed) is closed.

Problem:
. Config:   Change ComputerType
. Advanced: Load Saved-State
The 'Change ComputerType' msg is never posted.
This commit is contained in:
tomch 2012-03-31 21:34:02 +00:00
parent be71f901e0
commit 5478c4c9ed
16 changed files with 99 additions and 101 deletions

View File

@ -8,6 +8,6 @@ public:
protected:
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam) = 0;
virtual void DlgOK(HWND window, UINT afterclose) = 0;
virtual void DlgOK(HWND window) = 0;
virtual void DlgCANCEL(HWND window) = 0;
};

View File

@ -5,8 +5,6 @@
CPageAdvanced* CPageAdvanced::ms_this = 0; // reinit'd in ctor
//static bool g_bConfirmedRestartEmulator = false;
enum CLONECHOICE {MENUITEM_CLONEMIN, MENUITEM_PRAVETS82=MENUITEM_CLONEMIN, MENUITEM_PRAVETS8M, MENUITEM_PRAVETS8A, MENUITEM_CLONEMAX};
const TCHAR CPageAdvanced::m_CloneChoices[] =
TEXT("Pravets 82\0") // Bulgarian
@ -22,8 +20,6 @@ BOOL CALLBACK CPageAdvanced::DlgProc(HWND window, UINT message, WPARAM wparam, L
BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
static UINT afterclose = 0;
switch (message)
{
case WM_NOTIFY:
@ -34,6 +30,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
{
case PSN_SETACTIVE:
// About to become the active page
m_PropertySheetHelper.SetLastPage(m_Page);
InitFreezeDlgButton(window);
InitCloneDropdownMenu(window);
break;
@ -41,7 +38,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
SetWindowLong(window, DWL_MSGRESULT, FALSE); // Changes are valid
break;
case PSN_APPLY:
DlgOK(window, afterclose);
DlgOK(window);
SetWindowLong(window, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
break;
case PSN_QUERYCANCEL:
@ -72,10 +69,10 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
case IDC_SAVESTATE_ON_EXIT:
break;
case IDC_SAVESTATE:
afterclose = WM_USER_SAVESTATE;
m_uAfterClose = WM_USER_SAVESTATE;
break;
case IDC_LOADSTATE:
afterclose = WM_USER_LOADSTATE;
m_uAfterClose = WM_USER_LOADSTATE;
break;
//
@ -92,7 +89,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
&& m_PropertySheetHelper.IsOkToRestart(window) )
{
m_uTheFreezesF8Rom = uNewState;
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
}
else
@ -106,8 +103,6 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
case WM_INITDIALOG: //Init advanced settings dialog
{
m_PropertySheetHelper.SetLastPage(m_Page);
SendDlgItemMessage(window,IDC_SAVESTATE_FILENAME,WM_SETTEXT,0,(LPARAM)Snapshot_GetFilename());
CheckDlgButton(window, IDC_SAVESTATE_ON_EXIT, g_bSaveStateOnExit ? BST_CHECKED : BST_UNCHECKED);
@ -127,7 +122,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
// Need to specific cmd-line switch: -printer-real to enable this control
EnableWindow(GetDlgItem(window, IDC_DUMPTOPRINTER), g_bEnableDumpToRealPrinter ? TRUE : FALSE);
afterclose = 0;
m_uAfterClose = 0;
break;
}
}
@ -135,7 +130,7 @@ BOOL CPageAdvanced::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LP
return FALSE;
}
void CPageAdvanced::DlgOK(HWND window, UINT afterclose)
void CPageAdvanced::DlgOK(HWND window)
{
// Update save-state filename
{
@ -195,19 +190,16 @@ void CPageAdvanced::DlgOK(HWND window, UINT afterclose)
const DWORD NewCloneMenuItem = (DWORD) SendDlgItemMessage(window, IDC_CLONETYPE, CB_GETCURSEL, 0, 0);
const eApple2Type NewCloneType = GetCloneType(NewCloneMenuItem);
// Second msgbox fails:
// Get 2 identical msg-boxs:
// . Config tab: Change to 'Clone'
// . Advanced tab: Change clone type, then OK
// . ConfigDlg_OK() msgbox asks "restart now?", click OK
// . AdvancedDlg_OK() msgbox fails: GetLastError(): ERROR_INVALID_WINDOW_HANDLE; 1400 (0x578)
// - Probably because ConfigDlg_OK() has already posted WM_USER_RESTART
// - So I added g_bConfirmedRestartEmulator
// . AdvancedDlg_OK() msgbox asks "restart now?
if (IS_CLONE() || (m_PropertySheetHelper.GetUIControlCloneDropdownMenu() == UI_ENABLE))
{
if (NewCloneType != g_Apple2Type)
{
if ((afterclose == WM_USER_RESTART) || // Eg. Changing 'Freeze ROM' & user has already OK'd the restart for this
// g_bConfirmedRestartEmulator || // See above
if ((m_uAfterClose == WM_USER_RESTART) || // Eg. Changing 'Freeze ROM' & user has already OK'd the restart for this
((MessageBox(window,
TEXT(
"You have changed the emulated computer "
@ -219,7 +211,7 @@ void CPageAdvanced::DlgOK(HWND window, UINT afterclose)
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDOK)
&& m_PropertySheetHelper.IsOkToRestart(window)) )
{
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
m_PropertySheetHelper.SaveComputerType(NewCloneType);
}
}
@ -228,13 +220,7 @@ void CPageAdvanced::DlgOK(HWND window, UINT afterclose)
if (g_Apple2Type > A2TYPE_APPLE2PLUS)
m_uTheFreezesF8Rom = 0;
//
// if (g_bConfirmedRestartEmulator)
// return; // ConfigDlg_OK() has already posted WM_USER_RESTART
if (afterclose)
PostMessage(g_hFrameWindow,afterclose,0,0);
m_PropertySheetHelper.PostMsgAfterClose(m_Page, m_uAfterClose);
}
// Advanced->Clone: Menu item to eApple2Type

View File

@ -10,6 +10,7 @@ public:
CPageAdvanced(CPropertySheetHelper& PropertySheetHelper) :
m_Page(PG_ADVANCED),
m_PropertySheetHelper(PropertySheetHelper),
m_uAfterClose(0),
m_uTheFreezesF8Rom(0)
{
CPageAdvanced::ms_this = this;
@ -24,7 +25,7 @@ public:
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window){}
private:
@ -38,5 +39,6 @@ private:
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;
UINT m_uAfterClose;
UINT m_uTheFreezesF8Rom;
};

View File

@ -21,8 +21,6 @@ BOOL CALLBACK CPageConfig::DlgProc(HWND window, UINT message, WPARAM wparam, LPA
BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
static UINT afterclose = 0;
switch (message)
{
case WM_NOTIFY:
@ -31,6 +29,10 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
switch (((LPPSHNOTIFY)lparam)->hdr.code)
{
case PSN_SETACTIVE:
// About to become the active page
m_PropertySheetHelper.SetLastPage(m_Page);
break;
case PSN_KILLACTIVE:
// About to stop being active page
{
@ -41,7 +43,7 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
}
break;
case PSN_APPLY:
DlgOK(window, afterclose);
DlgOK(window);
SetWindowLong(window, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
break;
case PSN_QUERYCANCEL:
@ -73,7 +75,7 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
break;
case IDC_BENCHMARK:
afterclose = WM_USER_BENCHMARK;
m_uAfterClose = WM_USER_BENCHMARK;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
break;
@ -98,7 +100,7 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
TEXT("Configuration"),
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDOK)
{
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
}
break;
@ -112,8 +114,6 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
case WM_INITDIALOG: //Init general settings dialog
{
m_PropertySheetHelper.SetLastPage(m_Page);
// Convert Apple2 type to menu item
{
int nCurrentChoice = 0;
@ -154,7 +154,7 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
EnableTrackbar(window, bCustom);
}
afterclose = 0;
m_uAfterClose = 0;
break;
}
@ -184,7 +184,7 @@ BOOL CPageConfig::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPAR
return FALSE;
}
void CPageConfig::DlgOK(HWND window, UINT afterclose)
void CPageConfig::DlgOK(HWND window)
{
const DWORD NewComputerMenuItem = (DWORD) SendDlgItemMessage(window,IDC_COMPUTER,CB_GETCURSEL,0,0);
const DWORD newvidtype = (DWORD)SendDlgItemMessage(window,IDC_VIDEOTYPE,CB_GETCURSEL,0,0);
@ -195,8 +195,7 @@ void CPageConfig::DlgOK(HWND window, UINT afterclose)
if (NewApple2Type != OldApple2Type)
{
if ((afterclose == WM_USER_RESTART) || // Eg. Changing 'Freeze ROM' & user has already OK'd the restart for this
((MessageBox(window,
if ((MessageBox(window,
TEXT(
"You have changed the emulated computer "
"type. This change will not take effect "
@ -205,10 +204,9 @@ void CPageConfig::DlgOK(HWND window, UINT afterclose)
"Would you like to restart the emulator now?"),
TEXT("Configuration"),
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDOK)
&& m_PropertySheetHelper.IsOkToRestart(window)) )
&& m_PropertySheetHelper.IsOkToRestart(window))
{
//g_bConfirmedRestartEmulator = true;
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
m_PropertySheetHelper.SaveComputerType(NewApple2Type);
}
}
@ -242,10 +240,7 @@ void CPageConfig::DlgOK(HWND window, UINT afterclose)
Config_Save_Video();
//
if (afterclose)
PostMessage(g_hFrameWindow,afterclose,0,0);
m_PropertySheetHelper.PostMsgAfterClose(m_Page, m_uAfterClose);
}
// Config->Computer: Menu item to eApple2Type

View File

@ -10,7 +10,8 @@ class CPageConfig : public IPropertySheetPage
public:
CPageConfig(CPropertySheetHelper& PropertySheetHelper) :
m_Page(PG_CONFIG),
m_PropertySheetHelper(PropertySheetHelper)
m_PropertySheetHelper(PropertySheetHelper),
m_uAfterClose(0)
{
CPageConfig::ms_this = this;
}
@ -21,7 +22,7 @@ public:
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window){}
private:
@ -34,5 +35,6 @@ private:
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;
UINT m_uAfterClose;
CPageConfigTfe m_PageConfigTfe;
};

View File

@ -44,7 +44,7 @@ BOOL CPageConfigTfe::DlgProcInternal(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
switch (LOWORD(wparam))
{
case IDOK:
DlgOK(hwnd, 0);
DlgOK(hwnd);
/* FALL THROUGH */
case IDCANCEL:
@ -72,7 +72,7 @@ BOOL CPageConfigTfe::DlgProcInternal(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
return FALSE;
}
void CPageConfigTfe::DlgOK(HWND window, UINT afterclose)
void CPageConfigTfe::DlgOK(HWND window)
{
save_tfe_dialog(window);
}

View File

@ -17,7 +17,7 @@ public:
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window);
private:

View File

@ -19,8 +19,6 @@ BOOL CALLBACK CPageDisk::DlgProc(HWND window, UINT message, WPARAM wparam, LPARA
BOOL CPageDisk::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
static UINT afterclose = 0;
switch (message)
{
case WM_NOTIFY:
@ -29,11 +27,15 @@ BOOL CPageDisk::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM
switch (((LPPSHNOTIFY)lparam)->hdr.code)
{
case PSN_SETACTIVE:
// About to become the active page
m_PropertySheetHelper.SetLastPage(m_Page);
break;
case PSN_KILLACTIVE:
SetWindowLong(window, DWL_MSGRESULT, FALSE); // Changes are valid
break;
case PSN_APPLY:
DlgOK(window, afterclose);
DlgOK(window);
SetWindowLong(window, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
break;
case PSN_QUERYCANCEL:
@ -93,8 +95,6 @@ BOOL CPageDisk::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM
case WM_INITDIALOG: //Init disk settings dialog
{
m_PropertySheetHelper.SetLastPage(m_Page);
m_PropertySheetHelper.FillComboBox(window,IDC_DISKTYPE,m_discchoices,enhancedisk);
SendDlgItemMessage(window,IDC_EDIT_DISK1,WM_SETTEXT,0,(LPARAM)DiskGetFullName(DRIVE_1));
@ -115,7 +115,7 @@ BOOL CPageDisk::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM
EnableHDD(window, IsDlgButtonChecked(window, IDC_HDD_ENABLE));
afterclose = 0;
m_uAfterClose = 0;
break;
}
@ -216,7 +216,7 @@ BOOL CPageDisk::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM
return FALSE;
}
void CPageDisk::DlgOK(HWND window, UINT afterclose)
void CPageDisk::DlgOK(HWND window)
{
BOOL newdisktype = (BOOL) SendDlgItemMessage(window,IDC_DISKTYPE,CB_GETCURSEL,0,0);
@ -230,7 +230,7 @@ void CPageDisk::DlgOK(HWND window, UINT afterclose)
TEXT("Would you like to restart the emulator now?"),
TEXT("Configuration"),
MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND) == IDOK)
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
}
bool bHDDIsEnabled = IsDlgButtonChecked(window, IDC_HDD_ENABLE) ? true : false;
@ -242,10 +242,7 @@ void CPageDisk::DlgOK(HWND window, UINT afterclose)
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, HD_GetFullPathName(HARDDISK_1));
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, HD_GetFullPathName(HARDDISK_2));
//
if (afterclose)
PostMessage(g_hFrameWindow,afterclose,0,0);
m_PropertySheetHelper.PostMsgAfterClose(m_Page, m_uAfterClose);
}
void CPageDisk::EnableHDD(HWND window, BOOL bEnable)

View File

@ -9,7 +9,8 @@ class CPageDisk : public IPropertySheetPage
public:
CPageDisk(CPropertySheetHelper& PropertySheetHelper) :
m_Page(PG_DISK),
m_PropertySheetHelper(PropertySheetHelper)
m_PropertySheetHelper(PropertySheetHelper),
m_uAfterClose(0)
{
CPageDisk::ms_this = this;
}
@ -20,7 +21,7 @@ public:
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window){}
private:
@ -31,4 +32,5 @@ private:
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;
UINT m_uAfterClose;
};

View File

@ -40,7 +40,6 @@ BOOL CALLBACK CPageInput::DlgProc(HWND window, UINT message, WPARAM wparam, LPAR
BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
static UINT afterclose = 0;
m_MousecardSlotChange = CARD_UNCHANGED;
m_CPMcardSlotChange = CARD_UNCHANGED;
@ -52,11 +51,15 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
switch (((LPPSHNOTIFY)lparam)->hdr.code)
{
case PSN_SETACTIVE:
// About to become the active page
m_PropertySheetHelper.SetLastPage(m_Page);
break;
case PSN_KILLACTIVE:
SetWindowLong(window, DWL_MSGRESULT, FALSE); // Changes are valid
break;
case PSN_APPLY:
DlgOK(window, afterclose);
DlgOK(window);
SetWindowLong(window, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
break;
case PSN_QUERYCANCEL:
@ -140,7 +143,7 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
InitJoystickChoices(window, JN_JOYSTICK1, IDC_JOYSTICK1);
}
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
}
else
@ -176,7 +179,7 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
m_CPMcardSlotChange = (NewCPMChoice == CPM_UNPLUGGED) ? CARD_UNPLUGGED : CARD_INSERTED;
m_CPMChoice = NewCPMChoice;
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
}
else
@ -195,8 +198,6 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
case WM_INITDIALOG: //Init input settings dialog
{
m_PropertySheetHelper.SetLastPage(m_Page);
InitJoystickChoices(window, JN_JOYSTICK0, IDC_JOYSTICK0);
InitJoystickChoices(window, JN_JOYSTICK1, IDC_JOYSTICK1);
@ -220,7 +221,7 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
InitCPMChoices(window);
afterclose = 0;
m_uAfterClose = 0;
break;
}
}
@ -228,20 +229,20 @@ BOOL CPageInput::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
return FALSE;
}
void CPageInput::DlgOK(HWND window, UINT afterclose)
void CPageInput::DlgOK(HWND window)
{
UINT uNewJoyType0 = SendDlgItemMessage(window,IDC_JOYSTICK0,CB_GETCURSEL,0,0);
UINT uNewJoyType1 = SendDlgItemMessage(window,IDC_JOYSTICK1,CB_GETCURSEL,0,0);
if (!JoySetEmulationType(window, m_nJoy0ChoiceTranlationTbl[uNewJoyType0], JN_JOYSTICK0))
{
//afterclose = 0; // TC: does nothing
m_uAfterClose = 0;
return;
}
if (!JoySetEmulationType(window, m_nJoy1ChoiceTranlationTbl[uNewJoyType1], JN_JOYSTICK1))
{
//afterclose = 0; // TC: does nothing
m_uAfterClose = 0;
return;
}
@ -281,10 +282,7 @@ void CPageInput::DlgOK(HWND window, UINT afterclose)
m_PropertySheetHelper.SetSlot5(CT_Z80);
}
//
if (afterclose)
PostMessage(g_hFrameWindow,afterclose,0,0);
m_PropertySheetHelper.PostMsgAfterClose(m_Page, m_uAfterClose);
}
void CPageInput::InitJoystickChoices(HWND window, int nJoyNum, int nIdcValue)

View File

@ -10,6 +10,7 @@ public:
CPageInput(CPropertySheetHelper& PropertySheetHelper) :
m_Page(PG_INPUT),
m_PropertySheetHelper(PropertySheetHelper),
m_uAfterClose(0),
m_MousecardSlotChange(CARD_UNCHANGED),
m_CPMcardSlotChange(CARD_UNCHANGED),
m_uScrollLockToggle(0),
@ -33,7 +34,7 @@ public:
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window){}
private:
@ -66,6 +67,7 @@ private:
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;
UINT m_uAfterClose;
CARDSTATE m_MousecardSlotChange;
CARDSTATE m_CPMcardSlotChange;

View File

@ -19,8 +19,6 @@ BOOL CALLBACK CPageSound::DlgProc(HWND window, UINT message, WPARAM wparam, LPAR
BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
static UINT afterclose = 0;
switch (message)
{
case WM_NOTIFY:
@ -29,11 +27,15 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
switch (((LPPSHNOTIFY)lparam)->hdr.code)
{
case PSN_SETACTIVE:
// About to become the active page
m_PropertySheetHelper.SetLastPage(m_Page);
break;
case PSN_KILLACTIVE:
SetWindowLong(window, DWL_MSGRESULT, FALSE); // Changes are valid
break;
case PSN_APPLY:
DlgOK(window, afterclose);
DlgOK(window);
SetWindowLong(window, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
break;
case PSN_QUERYCANCEL:
@ -58,7 +60,7 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
LPCSTR pMsg = TEXT("The emulator needs to restart as the slot configuration has changed.\n")
TEXT("Mockingboard cards will be inserted into slots 4 & 5.\n\n")
TEXT("Would you like to restart the emulator now?");
if (NewSoundcardConfigured(window, wparam, pMsg, afterclose))
if (NewSoundcardConfigured(window, wparam, pMsg))
{
m_NewCardType = CT_MockingboardC;
m_SoundcardSlotChange = CARD_INSERTED;
@ -71,7 +73,7 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
LPCSTR pMsg = TEXT("The emulator needs to restart as the slot configuration has changed.\n")
TEXT("Phasor card will be inserted into slot 4.\n\n")
TEXT("Would you like to restart the emulator now?");
if (NewSoundcardConfigured(window, wparam, pMsg, afterclose))
if (NewSoundcardConfigured(window, wparam, pMsg))
{
m_NewCardType = CT_Phasor;
m_SoundcardSlotChange = CARD_INSERTED;
@ -84,7 +86,7 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
LPCSTR pMsg = TEXT("The emulator needs to restart as the slot configuration has changed.\n")
TEXT("Sound card(s) will be removed.\n\n")
TEXT("Would you like to restart the emulator now?");
if (NewSoundcardConfigured(window, wparam, pMsg, afterclose))
if (NewSoundcardConfigured(window, wparam, pMsg))
{
m_NewCardType = CT_Empty;
m_SoundcardSlotChange = CARD_UNPLUGGED;
@ -97,8 +99,6 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
case WM_INITDIALOG:
{
m_PropertySheetHelper.SetLastPage(m_Page);
m_PropertySheetHelper.FillComboBox(window,IDC_SOUNDTYPE,m_soundchoices,soundtype);
SendDlgItemMessage(window,IDC_SPKR_VOLUME,TBM_SETRANGE,1,MAKELONG(VOLUME_MIN,VOLUME_MAX));
@ -131,7 +131,7 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
EnableWindow(GetDlgItem(window, IDC_MB_VOLUME), (m_nCurrentIDCheckButton != IDC_SOUNDCARD_DISABLE) ? TRUE : FALSE);
afterclose = 0;
m_uAfterClose = 0;
break;
}
}
@ -139,7 +139,7 @@ BOOL CPageSound::DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARA
return FALSE;
}
void CPageSound::DlgOK(HWND window, UINT afterclose)
void CPageSound::DlgOK(HWND window)
{
DWORD newsoundtype = (DWORD)SendDlgItemMessage(window,IDC_SOUNDTYPE,CB_GETCURSEL,0,0);
@ -148,7 +148,7 @@ void CPageSound::DlgOK(HWND window, UINT afterclose)
if (!SpkrSetEmulationType(window,newsoundtype))
{
//afterclose = 0; // TC: does nothing
m_uAfterClose = 0;
return;
}
@ -183,13 +183,10 @@ void CPageSound::DlgOK(HWND window, UINT afterclose)
}
}
//
if (afterclose)
PostMessage(g_hFrameWindow,afterclose,0,0);
m_PropertySheetHelper.PostMsgAfterClose(m_Page, m_uAfterClose);
}
bool CPageSound::NewSoundcardConfigured(HWND window, WPARAM wparam, LPCSTR pMsg, UINT& afterclose)
bool CPageSound::NewSoundcardConfigured(HWND window, WPARAM wparam, LPCSTR pMsg)
{
if (HIWORD(wparam) != BN_CLICKED)
return false;
@ -204,7 +201,7 @@ bool CPageSound::NewSoundcardConfigured(HWND window, WPARAM wparam, LPCSTR pMsg,
&& m_PropertySheetHelper.IsOkToRestart(window) )
{
m_nCurrentIDCheckButton = LOWORD(wparam);
afterclose = WM_USER_RESTART;
m_uAfterClose = WM_USER_RESTART;
PropSheet_PressButton(GetParent(window), PSBTN_OK);
return true;
}

View File

@ -10,6 +10,7 @@ public:
CPageSound(CPropertySheetHelper& PropertySheetHelper) :
m_Page(PG_SOUND),
m_PropertySheetHelper(PropertySheetHelper),
m_uAfterClose(0),
m_NewCardType(CT_Empty),
m_SoundcardSlotChange(CARD_UNCHANGED),
m_nCurrentIDCheckButton(0)
@ -21,12 +22,12 @@ public:
static BOOL CALLBACK DlgProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
DWORD GetVolumeMax(void){ return VOLUME_MAX; }
bool NewSoundcardConfigured(HWND window, WPARAM wparam, LPCSTR pMsg, UINT& afterclose);
bool NewSoundcardConfigured(HWND window, WPARAM wparam, LPCSTR pMsg);
protected:
// IPropertySheetPage
virtual BOOL DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void DlgOK(HWND window, UINT afterclose);
virtual void DlgOK(HWND window);
virtual void DlgCANCEL(HWND window){}
private:
@ -34,6 +35,7 @@ private:
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;
UINT m_uAfterClose;
static const UINT VOLUME_MIN = 0;
static const UINT VOLUME_MAX = 59;

View File

@ -75,7 +75,6 @@ void CPropertySheet::Init(void)
PropSheetHeader.nStartPage = g_PropertySheetHelper.GetLastPage();
PropSheetHeader.ppsp = PropSheetPages;
// g_bConfirmedRestartEmulator = false;
g_PropertySheetHelper.SetUIControlFreezeDlgButton(UI_UNDEFINED);
g_PropertySheetHelper.SetUIControlCloneDropdownMenu(UI_UNDEFINED);
int i = PropertySheet(&PropSheetHeader); // Result: 0=Cancel, 1=OK

View File

@ -199,3 +199,11 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bo
m_bSSNewFilename = nRes ? true : false;
return nRes;
}
// On OK: Optionally post a single "uAfterClose" msg after last page closes
void CPropertySheetHelper::PostMsgAfterClose(PAGETYPE page, UINT uAfterClose)
{
m_bmPages &= ~(1<<(UINT32)page);
if (m_bmPages == 0 && uAfterClose)
PostMessage(g_hFrameWindow, uAfterClose, 0, 0);
}

View File

@ -6,6 +6,7 @@ class CPropertySheetHelper
public:
CPropertySheetHelper() :
m_LastPage(PG_CONFIG),
m_bmPages(0),
m_UIControlFreezeDlgButton(UI_UNDEFINED),
m_UIControlCloneDropdownMenu(UI_UNDEFINED),
m_bSSNewFilename(false)
@ -21,9 +22,15 @@ public:
void SaveStateUpdate();
void GetDiskBaseNameWithAWS(TCHAR* pszFilename);
int SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave);
void PostMsgAfterClose(PAGETYPE page, UINT uAfterClose);
PAGETYPE GetLastPage(void) { return m_LastPage; }
void SetLastPage(PAGETYPE page) { m_LastPage = page; }
void SetLastPage(PAGETYPE page)
{
m_LastPage = page;
m_bmPages |= 1<<(UINT32)page;
}
UICONTROLSTATE GetUIControlFreezeDlgButton(void) { return m_UIControlFreezeDlgButton; }
void SetUIControlFreezeDlgButton(UICONTROLSTATE state) { m_UIControlFreezeDlgButton = state; }
UICONTROLSTATE GetUIControlCloneDropdownMenu(void) { return m_UIControlCloneDropdownMenu; }
@ -33,6 +40,7 @@ public:
private:
PAGETYPE m_LastPage;
UINT32 m_bmPages;
UICONTROLSTATE m_UIControlFreezeDlgButton;
UICONTROLSTATE m_UIControlCloneDropdownMenu;
char m_szNewFilename[MAX_PATH];