From a0cb9c83ab6f586f53a33be7f323fe39091b95b7 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Fri, 13 May 2005 15:32:04 +0000 Subject: [PATCH] - error handling for network connection dialogs - implement "format disk" dialog svn path=/trunk/; revision=15263 --- reactos/subsys/system/winefile/Sv.rc | 2 +- reactos/subsys/system/winefile/cz.rc | 2 +- reactos/subsys/system/winefile/de.rc | 2 +- reactos/subsys/system/winefile/en.rc | 2 +- reactos/subsys/system/winefile/es.rc | 2 +- reactos/subsys/system/winefile/fr.rc | 2 +- reactos/subsys/system/winefile/hu.rc | 2 +- reactos/subsys/system/winefile/it.rc | 2 +- reactos/subsys/system/winefile/nl.rc | 2 +- reactos/subsys/system/winefile/pt.rc | 4 +-- reactos/subsys/system/winefile/resource.h | 1 + reactos/subsys/system/winefile/ru.rc | 2 +- reactos/subsys/system/winefile/si.rc | 2 +- reactos/subsys/system/winefile/winefile.c | 40 +++++++++++++++++++---- reactos/subsys/system/winefile/zh.rc | 2 +- 15 files changed, 49 insertions(+), 20 deletions(-) diff --git a/reactos/subsys/system/winefile/Sv.rc b/reactos/subsys/system/winefile/Sv.rc index 3f839c940d5..68e4b3033a4 100644 --- a/reactos/subsys/system/winefile/Sv.rc +++ b/reactos/subsys/system/winefile/Sv.rc @@ -59,7 +59,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Kopiera disk...", 201 MENUITEM "&Namnge disk...", 202 MENUITEM SEPARATOR - MENUITEM "&Formatera disk...", 203 + MENUITEM "&Formatera disk...", ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Skapa systemdisk...", -1 /*TODO*/ #endif diff --git a/reactos/subsys/system/winefile/cz.rc b/reactos/subsys/system/winefile/cz.rc index 0ee925446ef..156fcc13c0f 100644 --- a/reactos/subsys/system/winefile/cz.rc +++ b/reactos/subsys/system/winefile/cz.rc @@ -58,7 +58,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Kopírovat disk..." , 201 MENUITEM "&Jmenovka disk..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formátovat disk..." , 203 + MENUITEM "&Formátovat disk..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Vytvoøit systemový disk...", -1 /*TODO*/ #endif diff --git a/reactos/subsys/system/winefile/de.rc b/reactos/subsys/system/winefile/de.rc index 48058e5d02f..d4faadfc780 100644 --- a/reactos/subsys/system/winefile/de.rc +++ b/reactos/subsys/system/winefile/de.rc @@ -56,7 +56,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "Datenträger &kopieren..." , 201 MENUITEM "Datenträger &benennen..." , 202 MENUITEM SEPARATOR - MENUITEM "Datenträger &formatieren..." , 203 + MENUITEM "Datenträger &formatieren..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "...", -1 /*TODO*/ #endif diff --git a/reactos/subsys/system/winefile/en.rc b/reactos/subsys/system/winefile/en.rc index 0596809ade2..4da54e6ca3b 100644 --- a/reactos/subsys/system/winefile/en.rc +++ b/reactos/subsys/system/winefile/en.rc @@ -60,7 +60,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copy Disk..." , 201 MENUITEM "&Label Disk..." , 202 MENUITEM SEPARATOR - MENUITEM "&Format Disk..." , 203 + MENUITEM "&Format Disk..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Make System Disk...", -1 /*TODO*/ #endif diff --git a/reactos/subsys/system/winefile/es.rc b/reactos/subsys/system/winefile/es.rc index f800821267f..bfd57824576 100644 --- a/reactos/subsys/system/winefile/es.rc +++ b/reactos/subsys/system/winefile/es.rc @@ -56,7 +56,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copiar disco..." , 201 MENUITEM "E&tiquetar disco..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formatear disco..." , 203 + MENUITEM "&Formatear disco..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Hacer disco de sistema...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/fr.rc b/reactos/subsys/system/winefile/fr.rc index 967da7a01b3..d410c98b0d1 100644 --- a/reactos/subsys/system/winefile/fr.rc +++ b/reactos/subsys/system/winefile/fr.rc @@ -59,7 +59,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copier Disque..." , 201 MENUITEM "&Nommer Disque..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formater Disque..." , 203 + MENUITEM "&Formater Disque..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "Créer un disque *système...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/hu.rc b/reactos/subsys/system/winefile/hu.rc index 62c0a1c3d7b..6e61c521054 100644 --- a/reactos/subsys/system/winefile/hu.rc +++ b/reactos/subsys/system/winefile/hu.rc @@ -59,7 +59,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "Lemez &másolása..." , 201 MENUITEM "&Lemezcimke..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formatálás..." , 203 + MENUITEM "&Formatálás..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Rendszerlemez készítése...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/it.rc b/reactos/subsys/system/winefile/it.rc index 3230a56ede7..598caef2ef4 100644 --- a/reactos/subsys/system/winefile/it.rc +++ b/reactos/subsys/system/winefile/it.rc @@ -59,7 +59,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copia Disco..." , 201 MENUITEM "&Etichetta Disco..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formatta Disco..." , 203 + MENUITEM "&Formatta Disco..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Crea Disco di Sistema...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/nl.rc b/reactos/subsys/system/winefile/nl.rc index 8dbc15585e9..528aa8477ac 100644 --- a/reactos/subsys/system/winefile/nl.rc +++ b/reactos/subsys/system/winefile/nl.rc @@ -55,7 +55,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "Disk &kopiëren..." , 201 MENUITEM "Disklabel maken..." , 202 MENUITEM SEPARATOR - MENUITEM "Disk &formatteren..." , 203 + MENUITEM "Disk &formatteren..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "Systeemdisk maken...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/pt.rc b/reactos/subsys/system/winefile/pt.rc index 13a811b2b93..985b2194bbc 100644 --- a/reactos/subsys/system/winefile/pt.rc +++ b/reactos/subsys/system/winefile/pt.rc @@ -58,7 +58,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copiar disco..." , 201 MENUITEM "&Nomear disco..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formatar disco..." , 203 + MENUITEM "&Formatar disco..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Gerar disco de sistema...", -1 /*@@ */ #endif @@ -186,7 +186,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copiar disco..." , 201 MENUITEM "&Nomear disco..." , 202 MENUITEM SEPARATOR - MENUITEM "&Formatar disco..." , 203 + MENUITEM "&Formatar disco..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Gerar disco de sistema...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/resource.h b/reactos/subsys/system/winefile/resource.h index b41f647a934..edcbde6ac51 100644 --- a/reactos/subsys/system/winefile/resource.h +++ b/reactos/subsys/system/winefile/resource.h @@ -43,6 +43,7 @@ #define ID_EXECUTE 105 #define ID_FILE_MOVE 106 #define ID_FILE_EXIT 115 +#define ID_FORMAT_DISK 203 #define ID_CONNECT_NETWORK_DRIVE 252 #define ID_DISCONNECT_NETWORK_DRIVE 253 #define ID_VIEW_NAME 401 diff --git a/reactos/subsys/system/winefile/ru.rc b/reactos/subsys/system/winefile/ru.rc index caa4d2c170c..ead924fb18e 100644 --- a/reactos/subsys/system/winefile/ru.rc +++ b/reactos/subsys/system/winefile/ru.rc @@ -55,7 +55,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Êîïèðîâàòü äèñê..." , 201 MENUITEM "&Ìåòêà òîìà..." , 202 MENUITEM SEPARATOR - MENUITEM "&Ôîðìàòèðîâàòü..." , 203 + MENUITEM "&Ôîðìàòèðîâàòü..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Ñîçäàòü ñèñòåìíûé äèñê...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/si.rc b/reactos/subsys/system/winefile/si.rc index 5f014e896f7..947862b85ae 100644 --- a/reactos/subsys/system/winefile/si.rc +++ b/reactos/subsys/system/winefile/si.rc @@ -56,7 +56,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "&Copy Disk..." , 201 MENUITEM "&Label Disk..." , 202 MENUITEM SEPARATOR - MENUITEM "&Format Disk..." , 203 + MENUITEM "&Format Disk..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "&Make System Disk...", -1 /*@@ */ #endif diff --git a/reactos/subsys/system/winefile/winefile.c b/reactos/subsys/system/winefile/winefile.c index b15cfb3574e..7852cc488fb 100644 --- a/reactos/subsys/system/winefile/winefile.c +++ b/reactos/subsys/system/winefile/winefile.c @@ -260,6 +260,17 @@ static void display_error(HWND hwnd, DWORD error) } +/* display network error message using WNetGetLastError() */ +static void display_network_error(HWND hwnd) +{ + TCHAR msg[BUFFER_LEN], provider[BUFFER_LEN], b2[BUFFER_LEN]; + DWORD error; + + if (WNetGetLastError(&error, msg, BUFFER_LEN, provider, BUFFER_LEN) == NO_ERROR) + MessageBox(hwnd, msg, RS(b2,IDS_WINEFILE), MB_OK); +} + + /* allocate and initialise a directory entry */ static Entry* alloc_entry() { @@ -2000,13 +2011,30 @@ LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam } break;} - case ID_CONNECT_NETWORK_DRIVE: - WNetConnectionDialog(hwnd, RESOURCETYPE_DISK); - break; + case ID_CONNECT_NETWORK_DRIVE: { + DWORD ret = WNetConnectionDialog(hwnd, RESOURCETYPE_DISK); + if (ret!=NO_ERROR && ret!=(DWORD)-1) + if (ret == ERROR_EXTENDED_ERROR) + display_network_error(hwnd); + else + display_error(hwnd, ret); + break;} - case ID_DISCONNECT_NETWORK_DRIVE: - WNetDisconnectDialog(hwnd, RESOURCETYPE_DISK); - break; + case ID_DISCONNECT_NETWORK_DRIVE: { + DWORD ret = WNetDisconnectDialog(hwnd, RESOURCETYPE_DISK); + if (ret!=NO_ERROR && ret!=(DWORD)-1) + if (ret == ERROR_EXTENDED_ERROR) + display_network_error(hwnd); + else + display_error(hwnd, ret); + break;} + + case ID_FORMAT_DISK: { + UINT sem_org = SetErrorMode(0); /* Get the current Error Mode settings. */ + SetErrorMode(sem_org & ~SEM_FAILCRITICALERRORS); /* Force O/S to handle */ + SHFormatDrive(hwnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0); + SetErrorMode(sem_org); /* Put it back the way it was. */ + break;} case ID_HELP: WinHelp(hwnd, RS(b1,IDS_WINEFILE), HELP_INDEX, 0); diff --git a/reactos/subsys/system/winefile/zh.rc b/reactos/subsys/system/winefile/zh.rc index 95a1ef4b3a1..391539d5278 100644 --- a/reactos/subsys/system/winefile/zh.rc +++ b/reactos/subsys/system/winefile/zh.rc @@ -56,7 +56,7 @@ IDM_WINEFILE MENU FIXED IMPURE MENUITEM "¸´ÖÆ£¨&C£©..." , 201 MENUITEM "ÃüÃû£¨&L£©..." , 202 MENUITEM SEPARATOR - MENUITEM "¸ñʽ»¯£¨&£©..." , 203 + MENUITEM "¸ñʽ»¯£¨&£©..." , ID_FORMAT_DISK #ifdef _WIN95 MENUITEM "½¨Á¢ÏµÍ³ÅÌ£¨&M£©...", -1 /*@@ */ #endif