From 7df7cdb6e2c4f15c131cc90a872babab478e9619 Mon Sep 17 00:00:00 2001 From: Rolf Kalbermatter Date: Thu, 19 Dec 2002 04:11:22 +0000 Subject: [PATCH] Introduced some declarations and resources needed for a more complete implementation of SHFileOperation. --- dlls/shell32/shell32_main.h | 10 +++--- dlls/shell32/shfldr_fs.c | 2 +- dlls/shell32/shlfileop.c | 62 ++++++++++++++++++------------------- dlls/shell32/shres.rc | 2 ++ dlls/shell32/shresdef.h | 2 ++ 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index a48cf9d5e7a..efcfb0a3187 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -160,13 +160,15 @@ void InitChangeNotifications(void); void FreeChangeNotifications(void); /* file operation */ -#define ASK_DELETE_FILE 1 -#define ASK_DELETE_FOLDER 2 -#define ASK_DELETE_MULTIPLE_ITEM 3 +#define ASK_DELETE_FILE 1 +#define ASK_DELETE_FOLDER 2 +#define ASK_DELETE_MULTIPLE_ITEM 3 +#define ASK_CREATE_FOLDER 4 +#define ASK_OVERWRITE_FILE 5 BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI); BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI); -BOOL SHELL_WarnItemDelete(int nKindOfDialog, LPCSTR szDir); +BOOL SHELL_ConfirmDialog(int nKindOfDialog, LPCSTR szDir); /* 16-bit functions */ void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b); diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index 47090f0ab8c..ba184ee726b 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -978,7 +978,7 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPC char tmp[8]; snprintf (tmp, sizeof (tmp), "%d", cidl); - if (!SHELL_WarnItemDelete (ASK_DELETE_MULTIPLE_ITEM, tmp)) + if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM, tmp)) return E_FAIL; bConfirm = FALSE; } diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c index fe9236a04e1..a55145ce8b2 100644 --- a/dlls/shell32/shlfileop.c +++ b/dlls/shell32/shlfileop.c @@ -35,41 +35,39 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -BOOL SHELL_WarnItemDelete (int nKindOfDialog, LPCSTR szDir) +BOOL SHELL_ConfirmDialog (int nKindOfDialog, LPCSTR szDir) { char szCaption[255], szText[255], szBuffer[MAX_PATH + 256]; + UINT caption_resource_id, text_resource_id; - if(nKindOfDialog == ASK_DELETE_FILE) - { - LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText, - sizeof(szText)); - LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION, - szCaption, sizeof(szCaption)); - } - else if(nKindOfDialog == ASK_DELETE_FOLDER) - { - LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText, - sizeof(szText)); - LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, - szCaption, sizeof(szCaption)); - } - else if(nKindOfDialog == ASK_DELETE_MULTIPLE_ITEM) - { - LoadStringA(shell32_hInstance, IDS_DELETEMULTIPLE_TEXT, szText, - sizeof(szText)); - LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION, - szCaption, sizeof(szCaption)); - } - else { - FIXME("Called without a valid nKindOfDialog specified!\n"); - LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText, - sizeof(szText)); - LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION, - szCaption, sizeof(szCaption)); + switch(nKindOfDialog) { + + case ASK_DELETE_FILE: + caption_resource_id = IDS_DELETEITEM_CAPTION; + text_resource_id = IDS_DELETEITEM_TEXT; + break; + case ASK_DELETE_FOLDER: + caption_resource_id = IDS_DELETEFOLDER_CAPTION; + text_resource_id = IDS_DELETEITEM_TEXT; + break; + case ASK_DELETE_MULTIPLE_ITEM: + caption_resource_id = IDS_DELETEITEM_CAPTION; + text_resource_id = IDS_DELETEMULTIPLE_TEXT; + break; + case ASK_OVERWRITE_FILE: + caption_resource_id = IDS_OVERWRITEFILE_CAPTION; + text_resource_id = IDS_OVERWRITEFILE_TEXT; + break; + default: + FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog); + return FALSE; } - FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, - szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir); + LoadStringA(shell32_hInstance, caption_resource_id, szCaption, sizeof(szCaption)); + LoadStringA(shell32_hInstance, text_resource_id, szText, sizeof(szText)); + + FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, + szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir); return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION)); } @@ -91,7 +89,7 @@ BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI) PathAddBackslashA(szTemp); strcat(szTemp, "*.*"); - if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir)) + if (bShowUI && !SHELL_ConfirmDialog(ASK_DELETE_FOLDER, pszDir)) return FALSE; if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd))) @@ -124,7 +122,7 @@ BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI) BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI) { - if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FILE, pszFile)) + if (bShowUI && !SHELL_ConfirmDialog(ASK_DELETE_FILE, pszFile)) return FALSE; return DeleteFileA(pszFile); diff --git a/dlls/shell32/shres.rc b/dlls/shell32/shres.rc index 2f9d22406b3..8d4f1b62a0c 100644 --- a/dlls/shell32/shres.rc +++ b/dlls/shell32/shres.rc @@ -152,6 +152,8 @@ STRINGTABLE DISCARDABLE IDS_DELETEFOLDER_CAPTION "Confirm folder delete" IDS_DELETEITEM_TEXT "Are you sure you want to delete '%1'?" IDS_DELETEMULTIPLE_TEXT "Are you sure you want to delete these %1 items?" + IDS_OVERWRITEFILE_TEXT "OverWrite File %1?" + IDS_OVERWRITEFILE_CAPTION "Confirm File OverWrite" } shv_accel ACCELERATORS diff --git a/dlls/shell32/shresdef.h b/dlls/shell32/shresdef.h index 46615bb03d4..aa4685fca60 100644 --- a/dlls/shell32/shresdef.h +++ b/dlls/shell32/shresdef.h @@ -46,6 +46,8 @@ #define IDS_DELETEFOLDER_CAPTION 33 #define IDS_DELETEITEM_TEXT 34 #define IDS_DELETEMULTIPLE_TEXT 35 +#define IDS_OVERWRITEFILE_CAPTION 36 +#define IDS_OVERWRITEFILE_TEXT 37 /* browse for folder dialog box */ #define IDD_STATUS 0x3743