diff --git a/resource/Applewin.rc b/resource/Applewin.rc index 3ad41b44..1da8b7f6 100644 --- a/resource/Applewin.rc +++ b/resource/Applewin.rc @@ -13,13 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -162,28 +160,28 @@ BEGIN CONTROL "No sound cards",IDC_SOUNDCARD_DISABLE,"Button",BS_AUTORADIOBUTTON,10,163,78,10 END -IDD_PROPPAGE_DISK DIALOGEX 0, 0, 210, 190 +IDD_PROPPAGE_DISK DIALOGEX 0, 0, 211, 188 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION | WS_SYSMENU CAPTION "Disk" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "Floppy Disk Drives",IDC_STATIC,5,7,200,73 + GROUPBOX "Floppy Disk Drives",IDC_STATIC,5,7,200,72 LTEXT "&Disk access speed:",IDC_STATIC,12,21,64,8 COMBOBOX IDC_DISKTYPE,80,18,100,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Select Disk &1",IDC_DISK1,10,39,70,14 - EDITTEXT IDC_EDIT_DISK1,84,40,115,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "Select Disk &2",IDC_DISK2,10,60,70,14 - EDITTEXT IDC_EDIT_DISK2,84,60,115,12,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Hard Disk Drives",IDC_STATIC,5,85,200,71 + GROUPBOX "Hard Disk Drives",IDC_STATIC,5,83,200,64 CONTROL "&Enable hard disk controller in slot 7",IDC_HDD_ENABLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,98,122,10 - PUSHBUTTON "Select &HDD 1",IDC_HDD1,10,114,70,14 - EDITTEXT IDC_EDIT_HDD1,85,115,115,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "Selec&t HDD 2",IDC_HDD2,10,134,70,14 - EDITTEXT IDC_EDIT_HDD2,85,135,115,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "&Path to CiderPress:",IDC_STATIC,5,162,74,8 - EDITTEXT IDC_CIDERPRESS_FILENAME,5,172,143,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "&Browse...",IDC_CIDERPRESS_BROWSE,154,171,50,14 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,96,122,10 + LTEXT "&Path to CiderPress:",IDC_STATIC,7,155,74,8 + EDITTEXT IDC_CIDERPRESS_FILENAME,7,165,143,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "&Browse...",IDC_CIDERPRESS_BROWSE,156,164,50,14 + LTEXT "HDD 1:",IDC_STATIC,11,113,23,8 + LTEXT "HDD 2:",IDC_STATIC,11,130,23,8 + COMBOBOX IDC_COMBO_HDD1,46,112,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO_HDD2,46,128,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Disk 1:",IDC_STATIC,10,41,23,8 + LTEXT "Disk 2:",IDC_STATIC,10,58,23,8 + COMBOBOX IDC_COMBO_DISK1,40,40,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO_DISK2,40,57,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_TFE_SETTINGS_DIALOG DIALOGEX 0, 0, 270, 100 @@ -290,7 +288,7 @@ END // Accelerator // -IDR_ACCELERATOR1 ACCELERATORS +IDR_ACCELERATOR1 ACCELERATORS BEGIN "/", IDM_ABOUT, ASCII, ALT, NOINVERT "?", IDM_ABOUT, ASCII, ALT, NOINVERT @@ -329,7 +327,7 @@ IDR_FREEZES_F8_ROM ROM "FREEZES_NON-AUTOSTART_F8_ROM.ro // Menu // -IDR_MENU MENU +IDR_MENU MENU BEGIN POPUP "&File" BEGIN @@ -342,7 +340,7 @@ BEGIN END END -IDR_MENU_DISK_POPUP MENU +IDR_MENU_DISK_POPUP MENU BEGIN POPUP "Disk Menu" BEGIN @@ -353,7 +351,7 @@ BEGIN END END -IDR_MENU_DISK_CFG_POPUP MENU +IDR_MENU_DISK_CFG_POPUP MENU BEGIN POPUP "Disk Menu" BEGIN @@ -371,12 +369,22 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_PROPPAGE_INPUT, DIALOG BEGIN BOTTOMMARGIN, 182 END + + IDD_PROPPAGE_DISK, DIALOG + BEGIN + RIGHTMARGIN, 210 + BOTTOMMARGIN, 185 + END + + IDD_TFE_SETTINGS_DIALOG, DIALOG + BEGIN + END END #endif // APSTUDIO_INVOKED @@ -386,31 +394,29 @@ END // String Table // -STRINGTABLE +STRINGTABLE BEGIN IDS_TFE_CAPTION "Ethernet Settings" IDS_TFE_ETHERNET "Ethernet" IDS_TFE_INTERFACE "Interface" END -STRINGTABLE +STRINGTABLE BEGIN IDS_OK "OK" IDS_CANCEL "Cancel" END -#endif // English (U.S.) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// English (U.K.) resources +// English (United Kingdom) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -437,7 +443,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_ABOUT, DIALOG BEGIN @@ -449,7 +455,7 @@ BEGIN END #endif // APSTUDIO_INVOKED -#endif // English (U.K.) resources +#endif // English (United Kingdom) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/resource/resource.h b/resource/resource.h index 07eb4b73..15573251 100644 --- a/resource/resource.h +++ b/resource/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by APPLEWIN.RC +// Used by Applewin.rc // #define IDC_COMPUTER 101 #define IDC_JOYSTICK0 102 @@ -105,6 +105,10 @@ #define IDC_CURSORCONTROL 1066 #define IDC_AUTOFIRE 1067 #define IDC_CENTERINGCONTROL 1068 +#define IDC_COMBO_HDD1 1078 +#define IDC_COMBO_HDD2 1079 +#define IDC_COMBO_DISK1 1080 +#define IDC_COMBO_DISK2 1081 #define IDM_EXIT 40001 #define IDM_HELP 40002 #define IDM_ABOUT 40003 @@ -124,7 +128,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 147 #define _APS_NEXT_COMMAND_VALUE 40012 -#define _APS_NEXT_CONTROL_VALUE 1069 +#define _APS_NEXT_CONTROL_VALUE 1082 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 0545de84..896ab973 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -36,6 +36,13 @@ const TCHAR CPageDisk::m_discchoices[] = TEXT("Authentic Speed\0") TEXT("Enhanced Speed\0"); +const TCHAR CPageDisk::m_defaultDiskOptions[] = + TEXT("Select Disk...\0") + TEXT("Eject Disk\0"); + +const TCHAR CPageDisk::m_defaultHDDOptions[] = + TEXT("Select Hard Disk Image...\0") + TEXT("Unplug Hard Disk Image\0"); BOOL CALLBACK CPageDisk::DlgProc(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) { @@ -78,34 +85,28 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_COMMAND: switch (LOWORD(wparam)) { - case IDC_DISK1: - DiskSelect(DRIVE_1); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1)); - FrameRefreshStatus(DRAW_BUTTON_DRIVES); - break; - - case IDC_DISK2: - DiskSelect(DRIVE_2); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2)); - FrameRefreshStatus(DRAW_BUTTON_DRIVES); - break; - - case IDC_HDD1: - if(IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)) - { - HD_Select(HARDDISK_1); - SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1)); + case IDC_COMBO_DISK1: + if (HIWORD(wparam) == CBN_SELCHANGE) { + handleDiskCombo(hWnd, DRIVE_1, LOWORD(wparam)); + FrameRefreshStatus(DRAW_BUTTON_DRIVES); } break; - - case IDC_HDD2: - if(IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)) - { - HD_Select(HARDDISK_2); - SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2)); + case IDC_COMBO_DISK2: + if (HIWORD(wparam) == CBN_SELCHANGE) { + handleDiskCombo(hWnd, DRIVE_2, LOWORD(wparam)); + FrameRefreshStatus(DRAW_BUTTON_DRIVES); + } + break; + case IDC_COMBO_HDD1: + if (HIWORD(wparam) == CBN_SELCHANGE) { + handleHDDCombo(hWnd, HARDDISK_1, LOWORD(wparam)); + } + break; + case IDC_COMBO_HDD2: + if (HIWORD(wparam) == CBN_SELCHANGE) { + handleHDDCombo(hWnd, HARDDISK_2, LOWORD(wparam)); } break; - case IDC_HDD_ENABLE: EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)); break; @@ -123,21 +124,36 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_INITDIALOG: { m_PropertySheetHelper.FillComboBox(hWnd,IDC_DISKTYPE,m_discchoices,enhancedisk); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD1, m_defaultHDDOptions, hdd1Selection); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD2, m_defaultHDDOptions, hdd1Selection); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1)); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2)); + if (strlen(DiskGetFullName(DRIVE_1)) > 0) { + SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_1)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0); + } + if (strlen(DiskGetFullName(DRIVE_2)) > 0) { + SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_2)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0); + } - SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1)); - SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2)); + LPCTSTR hd = HD_GetFullName(HARDDISK_1); + if (strlen(hd)>0) { + SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_1)); + (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_SETCURSEL, 0, 0); + } - // + hd = HD_GetFullName(HARDDISK_2); + if (strlen(hd)>0) { + SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_2)); + (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_SETCURSEL, 0, 0); + } TCHAR PathToCiderPress[MAX_PATH] = ""; RegLoadString(TEXT("Configuration"), REGVALUE_CIDERPRESSLOC, 1, PathToCiderPress,MAX_PATH); SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME ,WM_SETTEXT, 0, (LPARAM)PathToCiderPress); - // - CheckDlgButton(hWnd, IDC_HDD_ENABLE, HD_CardIsEnabled() ? BST_CHECKED : BST_UNCHECKED); EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)); @@ -147,98 +163,6 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l break; } - case WM_RBUTTONUP: - { - RECT rect; // client area - POINT pt; // location of mouse click - - // Get the bounding rectangle of the client area. - GetClientRect(hWnd, (LPRECT) &rect); - - // Get the client coordinates for the mouse click. - pt.x = GET_X_LPARAM(lparam); - pt.y = GET_Y_LPARAM(lparam); - - // If the mouse click took place inside the client - // area, execute the application-defined function - // that displays the shortcut menu. - if (PtInRect((LPRECT) &rect, pt)) - { - // Load the menu template containing the shortcut menu from the application's resources. - HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_CFG_POPUP)); // menu template - _ASSERT(hMenu); - if (!hMenu) - break; - - // Get the first shortcut menu in the menu template. - // This is the menu that TrackPopupMenu displays. - HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); // shortcut menu - - // TrackPopup uses screen coordinates, so convert the coordinates of the mouse click to screen coordinates. - ClientToScreen(hWnd, (LPPOINT) &pt); - - if (Disk_IsDriveEmpty(DRIVE_1)) - EnableMenuItem(hMenu, ID_DISKMENU_EJECT_DISK1, MF_GRAYED); - if (Disk_IsDriveEmpty(DRIVE_2)) - EnableMenuItem(hMenu, ID_DISKMENU_EJECT_DISK2, MF_GRAYED); - if (HD_IsDriveUnplugged(HARDDISK_1)) - EnableMenuItem(hMenu, ID_DISKMENU_UNPLUG_HARDDISK1, MF_GRAYED); - if (HD_IsDriveUnplugged(HARDDISK_2)) - EnableMenuItem(hMenu, ID_DISKMENU_UNPLUG_HARDDISK2, MF_GRAYED); - - // Draw and track the shortcut menu. - int iCommand = TrackPopupMenu( - hMenuTrackPopup - , TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD - , pt.x, pt.y - , 0 - , hWnd, NULL ); - - if (iCommand) - { - TCHAR szText[100]; - bool bMsgBox = true; - if (iCommand == ID_DISKMENU_EJECT_DISK1 || iCommand == ID_DISKMENU_EJECT_DISK2) - wsprintf(szText, "Do you really want to eject the disk in drive-%c ?", '1'+iCommand-ID_DISKMENU_EJECT_DISK1); - else if (iCommand == ID_DISKMENU_UNPLUG_HARDDISK1 || iCommand == ID_DISKMENU_UNPLUG_HARDDISK2) - wsprintf(szText, "Do you really want to unplug harddisk-%c ?", '1'+iCommand-ID_DISKMENU_UNPLUG_HARDDISK1); - else - bMsgBox = false; - - if (bMsgBox) - { - int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_OKCANCEL | MB_SETFOREGROUND); - if (nRes == IDNO) - iCommand = 0; - } - } - - switch (iCommand) - { - case ID_DISKMENU_EJECT_DISK1: - DiskEject(DRIVE_1); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1)); - break; - case ID_DISKMENU_EJECT_DISK2: - DiskEject(DRIVE_2); - SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2)); - break; - case ID_DISKMENU_UNPLUG_HARDDISK1: - HD_Unplug(HARDDISK_1); - SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1)); - break; - case ID_DISKMENU_UNPLUG_HARDDISK2: - HD_Unplug(HARDDISK_2); - SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2)); - break; - } - - if (iCommand != 0) - FrameRefreshStatus(DRAW_BUTTON_DRIVES); - } - break; - } - } return FALSE; @@ -272,9 +196,112 @@ void CPageDisk::InitOptions(HWND hWnd) void CPageDisk::EnableHDD(HWND hWnd, BOOL bEnable) { - EnableWindow(GetDlgItem(hWnd, IDC_HDD1), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_EDIT_HDD1), bEnable); - - EnableWindow(GetDlgItem(hWnd, IDC_HDD2), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_EDIT_HDD2), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_COMBO_HDD1), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_COMBO_HDD2), bEnable); } + +void CPageDisk::handleHDDCombo(HWND hWnd, UINT16 driveSelected, UINT16 comboSelected) +{ + // Search from "select hard drive" + DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultHDDOptions[0]); + DWORD dwComboSelection = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_GETCURSEL, 0, 0); + if (IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)) { + if (dwComboSelection == dwOpenDialogIndex) { + (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); + HD_Select(driveSelected); + // Add hard drive name as item 0 and select it + if (dwOpenDialogIndex > 0) { + //Remove old item first + SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); + } + SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(driveSelected)); + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); + + // If the HD was in the other combo, remove now + DWORD comboOther = (comboSelected == IDC_COMBO_HDD1) ? IDC_COMBO_HDD2 : IDC_COMBO_HDD1; + + DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)HD_GetFullName(driveSelected)); + if (duplicated != CB_ERR) { + SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); + SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0); + } + } + else if (dwComboSelection == (dwOpenDialogIndex+1)){ + if (dwComboSelection > 1) { + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); + int iCommand = (driveSelected == 0) ? ID_DISKMENU_UNPLUG_HARDDISK1 : ID_DISKMENU_UNPLUG_HARDDISK2; + if (removalConfirmation(iCommand)) { + // unplug selected disk + HD_Unplug(driveSelected); + //Remove drive from list + SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); + } else { + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); + } + } + } + } +} + +void CPageDisk::handleDiskCombo(HWND hWnd, UINT16 driveSelected, UINT16 comboSelected) +{ + // Search from "select hard drive" + DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultDiskOptions[0]); + DWORD dwComboSelection = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_GETCURSEL, 0, 0); + if (dwComboSelection == dwOpenDialogIndex) { + (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); + DiskSelect(driveSelected); + // Add hard drive name as item 0 and select it + if (dwOpenDialogIndex > 0) { + //Remove old item first + SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); + } + SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(driveSelected)); + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); + + // If the HD was in the other combo, remove now + DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1; + + DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)DiskGetFullName(driveSelected)); + if (duplicated != CB_ERR) { + SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); + SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0); + } + } + else if (dwComboSelection == (dwOpenDialogIndex + 1)){ + if (dwComboSelection > 1) { + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, -1, 0); + int iCommand = (driveSelected == 0) ? ID_DISKMENU_EJECT_DISK1 : ID_DISKMENU_EJECT_DISK2; + if (removalConfirmation(iCommand)) { + // unplug selected disk + DiskEject(driveSelected); + //Remove drive from list + SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); + } + else { + SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); + } + } + } +} + + +int CPageDisk::removalConfirmation(int iCommand) +{ + TCHAR szText[100]; + bool bMsgBox = true; + if (iCommand == ID_DISKMENU_EJECT_DISK1 || iCommand == ID_DISKMENU_EJECT_DISK2) + wsprintf(szText, "Do you really want to eject the disk in drive-%c ?", '1' + iCommand - ID_DISKMENU_EJECT_DISK1); + else if (iCommand == ID_DISKMENU_UNPLUG_HARDDISK1 || iCommand == ID_DISKMENU_UNPLUG_HARDDISK2) + wsprintf(szText, "Do you really want to unplug harddisk-%c ?", '1' + iCommand - ID_DISKMENU_UNPLUG_HARDDISK1); + else + bMsgBox = false; + + if (bMsgBox) + { + int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); + if (nRes == IDNO) + iCommand = 0; + } + return iCommand; +} \ No newline at end of file diff --git a/source/Configuration/PageDisk.h b/source/Configuration/PageDisk.h index bae7477a..7a8fcdb7 100644 --- a/source/Configuration/PageDisk.h +++ b/source/Configuration/PageDisk.h @@ -12,6 +12,9 @@ public: m_PropertySheetHelper(PropertySheetHelper) { CPageDisk::ms_this = this; + + hdd1Selection = -1; + hdd2Selection = -1; } virtual ~CPageDisk(){} @@ -26,9 +29,17 @@ protected: private: void InitOptions(HWND hWnd); void EnableHDD(HWND hWnd, BOOL bEnable); + void handleHDDCombo(HWND hWnd, UINT16 driveSelected, UINT16 comboSelected); + void handleDiskCombo(HWND hWnd, UINT16 driveSelected, UINT16 comboSelected); + int removalConfirmation(int iCommand); static CPageDisk* ms_this; static const TCHAR m_discchoices[]; + static const TCHAR m_defaultDiskOptions[]; + static const TCHAR m_defaultHDDOptions[]; + + int hdd1Selection; + int hdd2Selection; const PAGETYPE m_Page; CPropertySheetHelper& m_PropertySheetHelper; diff --git a/source/Disk.cpp b/source/Disk.cpp index 6fcff6ff..ed73b31b 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -610,6 +610,12 @@ ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool b else fptr->bWriteProtected = bForceWriteProtected ? true : (dwAttributes & FILE_ATTRIBUTE_READONLY); + // Check if image is being used by the other HDD, and unplug it in order to be swapped + std::string otherDisk = DiskGetDiskPathFilename(!iDrive); + if (!strcmp(otherDisk.c_str(), pszImageFilename)) { + DiskEject(!iDrive); + } + ImageError_e Error = ImageOpen(pszImageFilename, &fptr->imagehandle, &fptr->bWriteProtected, diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 0a9964ad..3406140e 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -353,6 +353,11 @@ BOOL HD_InsertDisk(const int iDrive, LPCTSTR pszImageFilename) if (g_HardDisk[iDrive].hd_imageloaded) HD_CleanupDrive(iDrive); + // Check if image is being used by the other HDD, and unplug it in order to be swapped + if (!strcmp(HD_GetFullPathName(!iDrive), pszImageFilename)) { + HD_Unplug(!iDrive); + } + BOOL bResult = HD_Load_Image(iDrive, pszImageFilename); if (bResult)