Skip to content

Commit

Permalink
Replace format floppy disk with standard format drive dialog #108
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjustice authored and craigwi committed Apr 28, 2018
1 parent bb587de commit ea0dd95
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 37 deletions.
5 changes: 3 additions & 2 deletions src/lang/res_en-US.rc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BEGIN
MENUITEM "&Copy Disk...", IDM_DISKCOPY
MENUITEM "&Label Disk...", IDM_LABEL
MENUITEM SEPARATOR
MENUITEM "&Format Disk...", IDM_FORMAT
MENUITEM "&Format Drive...", IDM_FORMAT
MENUITEM SEPARATOR
MENUITEM "&Select Drive...", IDM_DRIVESMORE
END
Expand Down Expand Up @@ -323,6 +323,7 @@ JAPANEND
IDS_BUSYFORMATQUITVERIFY "File Manager is currently formatting a disk. Exiting File Manager will abort this operation."
IDS_BUSYCOPYQUITVERIFY "File Manager is currently copying a disk. Exiting File Manager will abort this operation."
IDS_PERCENTCOMPLETE "Percent Complete"
IDS_FORMATSELECTDLGTITLE "Format Drive"

IDS_12MB "1%s2 MB"
IDS_360KB "360K"
Expand Down Expand Up @@ -550,7 +551,7 @@ BEGIN

MH_MYITEMS+IDM_DISKCOPY, "Copies the contents of a floppy disk"
MH_MYITEMS+IDM_LABEL, "Assigns or changes a disk's volume label"
MH_MYITEMS+IDM_FORMAT, "Formats a floppy disk"
MH_MYITEMS+IDM_FORMAT, "Formats a drive"
// MH_MYITEMS+IDM_SYSDISK, "Copies MS-DOS files to a floppy disk"
MH_MYITEMS+IDM_CONNECT, "Connects to a network drive"
MH_MYITEMS+IDM_DISCONNECT, "Disconnects from a network drive"
Expand Down
1 change: 1 addition & 0 deletions src/lang/res_ja-JP.rc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ JAPANEND
IDS_BUSYFORMATQUITVERIFY "現在ファイル マネージャーはフロッピー ディスクをフォーマットしています。ファイル マネージャーを終了すると、この操作が中断されます。"
IDS_BUSYCOPYQUITVERIFY "現在ファイル マネージャーはフロッピー ディスクをコピーしています。ファイル マネージャーを終了すると、この操作が中断されます。"
IDS_PERCENTCOMPLETE "完了の割合"
IDS_FORMATSELECTDLGTITLE "Format Drive"

IDS_12MB "1%s2 MB"
IDS_360KB "360K"
Expand Down
1 change: 1 addition & 0 deletions src/lang/res_pl-PL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ JAPANEND
IDS_BUSYFORMATQUITVERIFY "Menedżer plików obecnie formatuje dysk. Zakończenie działania Menedżera plików spowoduje przerwanie tej operacji."
IDS_BUSYCOPYQUITVERIFY "Menedżer plików obecnie kopiuje dysk. Zakończenie działania Menedżera plików spowoduje przerwanie tej operacji."
IDS_PERCENTCOMPLETE "Procent ukończono"
IDS_FORMATSELECTDLGTITLE "Format Drive"

IDS_12MB "1%s2 MB"
IDS_360KB "360K"
Expand Down
1 change: 1 addition & 0 deletions src/lang/res_zh-CN.rc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ JAPANEND
IDS_BUSYFORMATQUITVERIFY "文件管理器当前正在格式化软盘。退出文件管理器将会中断此项操作。"
IDS_BUSYCOPYQUITVERIFY "文件管理器当前正在复制软盘。退出文件管理器将会中断此项操作。"
IDS_PERCENTCOMPLETE "完成百分比"
IDS_FORMATSELECTDLGTITLE "Format Drive"

IDS_12MB "1%s2 MB"
IDS_360KB "360K"
Expand Down
10 changes: 10 additions & 0 deletions src/lang/winfile_en-US.dlg
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ BEGIN
CONTROL "&Quick Format", IDD_VERIFY, "button", BS_CHECKBOX | BS_AUTOCHECKBOX | WS_TABSTOP | WS_CHILD, 11, 62, 90, 12
END

FORMATSELECTDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 11, 28, 183, 44
CAPTION "Format Drive"
FONT 8, "MS Shell Dlg"
STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME | WS_POPUP
BEGIN
CONTROL "OK", 1, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 6, 40, 14
CONTROL "Cancel", 2, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 23, 40, 14
CONTROL "&Drive to format:", -1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 7, 49, 10
CONTROL "", IDD_SELECTDRIVE, "combobox", CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL | WS_CHILD, 55, 4, 65, 40
END

FORMATPROGRESSDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 30, 150, 50
CAPTION "Formatting Disk"
Expand Down
10 changes: 10 additions & 0 deletions src/lang/winfile_ja-JP.dlg
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ BEGIN
CONTROL "クイック フォーマット(&Q)", IDD_VERIFY, "button", BS_CHECKBOX | BS_AUTOCHECKBOX | WS_TABSTOP | WS_CHILD, 11, 62, 90, 12
END

FORMATSELECTDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 11, 28, 183, 44
CAPTION "Format Drive"
FONT 8, "MS Shell Dlg"
STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME | WS_POPUP
BEGIN
CONTROL "OK", 1, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 6, 40, 14
CONTROL "Cancel", 2, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 23, 40, 14
CONTROL "&Drive to format:", -1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 7, 49, 10
CONTROL "", IDD_SELECTDRIVE, "combobox", CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL | WS_CHILD, 55, 4, 65, 40
END

FORMATPROGRESSDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 30, 150, 50
CAPTION "ディスクをフォーマット中"
Expand Down
10 changes: 10 additions & 0 deletions src/lang/winfile_pl-PL.dlg
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,16 @@ BEGIN
CONTROL "&Szybkie formatowanie", IDD_VERIFY, "button", BS_CHECKBOX | BS_AUTOCHECKBOX | WS_TABSTOP | WS_CHILD, 11, 62, 90, 12
END

FORMATSELECTDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 11, 28, 183, 44
CAPTION "Format Drive"
FONT 8, "MS Shell Dlg"
STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME | WS_POPUP
BEGIN
CONTROL "OK", 1, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 6, 40, 14
CONTROL "Cancel", 2, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 23, 40, 14
CONTROL "&Drive to format:", -1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 7, 49, 10
CONTROL "", IDD_SELECTDRIVE, "combobox", CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL | WS_CHILD, 55, 4, 65, 40
END

FORMATPROGRESSDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 30, 150, 50
CAPTION "Formatowanie dysku"
Expand Down
10 changes: 10 additions & 0 deletions src/lang/winfile_zh-CN.dlg
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ BEGIN
CONTROL "快速格式化(&Q)", IDD_VERIFY, "button", BS_CHECKBOX | BS_AUTOCHECKBOX | WS_TABSTOP | WS_CHILD, 11, 62, 90, 12
END

FORMATSELECTDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 11, 28, 183, 44
CAPTION "Format Drive"
FONT 8, "MS Shell Dlg"
STYLE WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_VISIBLE | DS_MODALFRAME | WS_POPUP
BEGIN
CONTROL "OK", 1, "button", BS_DEFPUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 6, 40, 14
CONTROL "Cancel", 2, "button", BS_PUSHBUTTON | WS_TABSTOP | WS_CHILD, 140, 23, 40, 14
CONTROL "&Drive to format:", -1, "static", SS_LEFTNOWORDWRAP | WS_CHILD, 5, 7, 49, 10
CONTROL "", IDD_SELECTDRIVE, "combobox", CBS_DROPDOWNLIST | WS_TABSTOP | WS_VSCROLL | WS_CHILD, 55, 4, 65, 40
END

FORMATPROGRESSDLG DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 30, 150, 50
CAPTION "正在格式化磁盘"
Expand Down
2 changes: 2 additions & 0 deletions src/res.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@

#define IDS_PERCENTCOMPLETE 326

#define IDS_FORMATSELECTDLGTITLE 327

#define IDS_DRIVEBASE 350
#define IDS_12MB 354
#define IDS_360KB 353
Expand Down
27 changes: 8 additions & 19 deletions src/wfcomman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1626,28 +1626,17 @@ AppCommandProc(register DWORD id)

case IDM_FORMAT:

if (CancelInfo.hCancelDlg) {
SetFocus(CancelInfo.hCancelDlg);
break;
if (!hwndFormatSelect)
{
hwndFormatSelect = CreateDialog(hAppInstance, (LPTSTR)MAKEINTRESOURCE(FORMATSELECTDLG),
hwndFrame, (DLGPROC)FormatSelectDlgProc);
}

if (CancelInfo.hThread) {
//
// Don't create any new worker threads
// Just create old dialog
//

CreateDialog(hAppInstance, (LPTSTR) MAKEINTRESOURCE(CANCELDLG), hwndFrame, (DLGPROC) CancelDlgProc);

return TRUE;
else
{
ShowWindow(hwndFormatSelect, SW_SHOW);
SetActiveWindow(hwndFormatSelect);
}

if (!FmifsLoaded())
break;

// Don't use modal dialog box

FormatDiskette(hwndFrame,FALSE);
break;

case IDM_SHAREAS:
Expand Down
6 changes: 4 additions & 2 deletions src/wfdlgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@
#define UNCOMPRESSPROGDLG 58
#define COMPRESSERRDLG 59 // Compression Error Dialog

#define GOTODIRDLG 60
#define ABOUTDLG 61
#define GOTODIRDLG 60
#define ABOUTDLG 61
#define FORMATSELECTDLG 62

#define IDD_TEXT -1
#define IDD_TEXT1 100
Expand Down Expand Up @@ -208,6 +209,7 @@

#define IDD_GOTODIR 355
#define IDD_GOTOLIST 356
#define IDD_SELECTDRIVE 357

#define IDD_ASSOCFIRST 100
#define IDD_ASSOCLAST 109
Expand Down
113 changes: 100 additions & 13 deletions src/wfdlgs3.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
#include "winfile.h"
#include "lfn.h"
#include "wfcopy.h"
#include <shlobj.h>

#define LABEL_NTFS_MAX 32
#define LABEL_FAT_MAX 11
#define CCH_VERSION 40
#define CCH_DRIVE 3
#define CCH_DLG_TITLE 16

VOID FormatDrive( IN PVOID ThreadParameter );
VOID CopyDiskette( IN PVOID ThreadParameter );
Expand Down Expand Up @@ -727,6 +730,93 @@ FormatDlgProc(register HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
return TRUE;
}

/*----------------------------------------------------------------------------*/
/* */
/* FormatSelectDlgProc() - DialogProc callback function for FORMATSELECTDLG */
/* */
/*----------------------------------------------------------------------------*/

INT_PTR
FormatSelectDlgProc(register HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndSelectDrive;
INT driveIndex;
INT comboxIndex;
DRIVE drive;
DWORD dwFormatResult;
TCHAR szDrive[CCH_DRIVE] = { 0 };
TCHAR szDlgTitle[CCH_DLG_TITLE] = { 0 };

switch (wMsg)
{
case WM_INITDIALOG:
{
// Build the list of drives that can be selected for formatting.
// Do not include remote drives or CD/DVD drives.
szDrive[1] = ':';
hwndSelectDrive = GetDlgItem(hDlg, IDD_SELECTDRIVE);
if (hwndSelectDrive)
{
for (driveIndex = 0; driveIndex < cDrives; driveIndex++)
{
drive = rgiDrive[driveIndex];
if (!IsRemoteDrive(drive) && !IsCDRomDrive(drive))
{
// Set the drive letter as the string and the drive index as the data.
DRIVESET(szDrive, drive);
comboxIndex = SendMessage(hwndSelectDrive, CB_ADDSTRING, 0, (LPARAM)szDrive);
SendMessage(hwndSelectDrive, CB_SETITEMDATA, comboxIndex, (LPARAM)drive);
}
}

SendMessage(hwndSelectDrive, CB_SETCURSEL, 0, 0);
}

return TRUE;
}
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
{
// Hide this dialog window while the SHFormatDrive dialog is displayed.
// SHFormatDrive needs a parent window, and this dialog will serve as
// that parent, even if it is hidden.
ShowWindow(hDlg, SW_HIDE);

// Retrieve the selected drive index and call SHFormatDrive with it.
comboxIndex = (INT)SendDlgItemMessage(hDlg, IDD_SELECTDRIVE, CB_GETCURSEL, 0, 0);
drive = (DRIVE)SendDlgItemMessage(hDlg, IDD_SELECTDRIVE, CB_GETITEMDATA, comboxIndex, 0);
dwFormatResult = SHFormatDrive(hDlg, drive, SHFMT_ID_DEFAULT, 0);

// If the format results in an error, show FORMATSELECTDLG again so
// the user can select a different drive if needed, or cancel.
// Otherwise, if the format was successful, just close FORMATSELECTDLG.
if (dwFormatResult == SHFMT_ERROR || dwFormatResult == SHFMT_CANCEL || dwFormatResult == SHFMT_NOFORMAT)
{
// SHFormatDrive sometimes sets the parent window title when it encounters an error.
// We don't want this; set the title back before we show the dialog.
LoadString(hAppInstance, IDS_FORMATSELECTDLGTITLE, szDlgTitle, CCH_DLG_TITLE);
SetWindowText(hDlg, szDlgTitle);
ShowWindow(hDlg, SW_SHOW);
}
else
{
DestroyWindow(hDlg);
hwndFormatSelect = NULL;
}

return TRUE;
}
case IDCANCEL:
DestroyWindow(hDlg);
hwndFormatSelect = NULL;
return TRUE;
}
}
return FALSE;
}

/*--------------------------------------------------------------------------*/
/* */
/* AboutDlgProc() - DialogProc callback function for ABOUTDLG */
Expand Down Expand Up @@ -1674,22 +1764,19 @@ LockFormatDisk(DRIVE drive1, DRIVE drive2,
DWORD dwMessage, DWORD dwCommand, BOOL bLock)
{
HMENU hMenu;
static DWORD adwCommands[] = {
IDM_DISKCOPY,
IDM_FORMAT,
0
};

INT i=0;

// Gray out disk:{format,copy}
// Gray out menu item dwCommand
hMenu = GetMenu(hwndFrame);

while (adwCommands[i]) {
if (dwCommand != adwCommands[i])
EnableMenuItem( hMenu, dwCommand ,
bLock ? MF_BYCOMMAND | MF_GRAYED : MF_BYCOMMAND | MF_ENABLED );
i++;
// Special case for IDM_FORMAT, as it no longer invokes FormatDiskette,
// it can be safely left enabled even when copying diskettes.
// This change is made here rather than removing the calls to
// LockFormatDisk with IDM_FORMAT since LockFormatDisk also
// changes the state of aDriveInfo.
if (dwCommand != IDM_FORMAT)
{
EnableMenuItem(hMenu, dwCommand,
bLock ? MF_BYCOMMAND | MF_GRAYED : MF_BYCOMMAND | MF_ENABLED);
}

//
Expand Down
1 change: 0 additions & 1 deletion src/wfinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ InitMenus()

if (nFloppies == 0) {
EnableMenuItem(hMenu, IDM_DISKCOPY, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hMenu, IDM_FORMAT, MF_BYCOMMAND | MF_GRAYED);
}


Expand Down
3 changes: 3 additions & 0 deletions src/winfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,9 @@ bDialogMessage(PMSG pMsg)
!CancelInfo.bModal &&
IsDialogMessage(CancelInfo.hCancelDlg, pMsg)) ||

(hwndFormatSelect &&
IsDialogMessage(hwndFormatSelect, pMsg)) ||

(SearchInfo.hSearchDlg &&
IsDialogMessage(SearchInfo.hSearchDlg, pMsg)))

Expand Down
2 changes: 2 additions & 0 deletions src/winfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ INT_PTR ExitDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
INT_PTR DiskLabelDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
INT_PTR ChooseDriveDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
INT_PTR FormatDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
INT_PTR FormatSelectDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OtherDlgProc(register HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);

INT_PTR ProgressDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
Expand Down Expand Up @@ -1305,6 +1306,7 @@ Extern HWND hwndDriveBar EQ( NULL );
Extern HWND hwndToolbar EQ( NULL );
Extern HWND hwndDriveList EQ( NULL );
Extern HWND hwndDropChild EQ( NULL ); // for tree windows forwarding to drivebar
Extern HWND hwndFormatSelect EQ( NULL );

Extern BOOL bCancelTree;

Expand Down

3 comments on commit ea0dd95

@thecatkitty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this commit made me wonder: How should we (in the organizational sense) handle situations when some change of the codebase creates new messages to translate? Because then we're going to have every translator creating a new, separate and perhaps even one-line, commit creating translation for their language.

@matthewjustice
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thecatkitty - I was thinking about that myself. Seems at a minimum we need to create an issue so that the need for localization is tracked. Or maybe an issue per language so they can be closed independently? Either way, we end up with a lot of separate commits from the translators, unless they handle the work in batches.

I'll create an issue to track the work for this particular commit and see how it goes.

@matthewjustice
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #149. We can try a different approach if that doesn't work.

Please sign in to comment.