From 84234a9add21e58101607052411447d28f4ffd0f Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 22 Apr 2007 17:55:11 +0000 Subject: [PATCH] Add message boxes to confirm the removal of user cursor schemes and the replacement of existing cursor schemes. svn path=/trunk/; revision=26466 --- reactos/dll/cpl/main/lang/cs-CZ.rc | 4 + reactos/dll/cpl/main/lang/de-DE.rc | 5 ++ reactos/dll/cpl/main/lang/en-US.rc | 4 + reactos/dll/cpl/main/lang/es-ES.rc | 4 + reactos/dll/cpl/main/lang/fr-FR.rc | 4 + reactos/dll/cpl/main/lang/hu-HU.rc | 4 + reactos/dll/cpl/main/lang/id-ID.rc | 4 + reactos/dll/cpl/main/lang/it-IT.rc | 4 + reactos/dll/cpl/main/lang/ja-JP.rc | 4 + reactos/dll/cpl/main/lang/nl-NL.rc | 4 + reactos/dll/cpl/main/lang/pl-PL.rc | 4 + reactos/dll/cpl/main/lang/ru-RU.rc | 4 + reactos/dll/cpl/main/lang/uk-UA.rc | 4 + reactos/dll/cpl/main/mouse.c | 126 ++++++++++++++++++++--------- reactos/dll/cpl/main/resource.h | 5 +- 15 files changed, 143 insertions(+), 41 deletions(-) diff --git a/reactos/dll/cpl/main/lang/cs-CZ.rc b/reactos/dll/cpl/main/lang/cs-CZ.rc index f98d652dcd2..c4df8b15e82 100644 --- a/reactos/dll/cpl/main/lang/cs-CZ.rc +++ b/reactos/dll/cpl/main/lang/cs-CZ.rc @@ -163,4 +163,8 @@ BEGIN IDS_SYSTEM_SCHEME "(systémové schéma)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/de-DE.rc b/reactos/dll/cpl/main/lang/de-DE.rc index 09b4ebe0b07..ac02bdcf11a 100644 --- a/reactos/dll/cpl/main/lang/de-DE.rc +++ b/reactos/dll/cpl/main/lang/de-DE.rc @@ -165,4 +165,9 @@ BEGIN IDS_SYSTEM_SCHEME "(Systemschema)" IDS_BROWSE_FILTER "Cursor (*.ani, *.cur)\0*.ani;*.cur\0Animierte Cursor (*.ani)\0*.ani\0Statische Cursor (*.cur)\0*.cur\0Alle Dateien\0*.*\0\0" IDS_BROWSE_TITLE "Durchsuchen" + IDS_REMOVE_TITLE "Löschen des Cursorschemas bestätigen" + IDS_REMOVE_TEXT "Soll das Cursorschema '%s' wirklich gelöscht werden?" + IDS_OVERWRITE_TITLE "Cursorschema überscheiben" + IDS_OVERWRITE_TEXT "Ein Cursorschema mit diesem Namen existiert bereits. Möchen Sie das existierende Cursorschema überscheiben?" END + diff --git a/reactos/dll/cpl/main/lang/en-US.rc b/reactos/dll/cpl/main/lang/en-US.rc index 336b550d5b6..5bc9b914f59 100644 --- a/reactos/dll/cpl/main/lang/en-US.rc +++ b/reactos/dll/cpl/main/lang/en-US.rc @@ -163,4 +163,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Cursor Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/es-ES.rc b/reactos/dll/cpl/main/lang/es-ES.rc index 89b0cfe677e..8c33763bde0 100644 --- a/reactos/dll/cpl/main/lang/es-ES.rc +++ b/reactos/dll/cpl/main/lang/es-ES.rc @@ -164,4 +164,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/fr-FR.rc b/reactos/dll/cpl/main/lang/fr-FR.rc index 6be9fe69f12..cdab99d4ec1 100644 --- a/reactos/dll/cpl/main/lang/fr-FR.rc +++ b/reactos/dll/cpl/main/lang/fr-FR.rc @@ -164,4 +164,8 @@ BEGIN IDS_SYSTEM_SCHEME "(Arrangement système)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/hu-HU.rc b/reactos/dll/cpl/main/lang/hu-HU.rc index 618a74b5444..05690ef229a 100644 --- a/reactos/dll/cpl/main/lang/hu-HU.rc +++ b/reactos/dll/cpl/main/lang/hu-HU.rc @@ -164,4 +164,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/id-ID.rc b/reactos/dll/cpl/main/lang/id-ID.rc index 1a4ab91fef2..921d37690f8 100644 --- a/reactos/dll/cpl/main/lang/id-ID.rc +++ b/reactos/dll/cpl/main/lang/id-ID.rc @@ -163,4 +163,8 @@ BEGIN IDS_SYSTEM_SCHEME "(skema sistem)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/it-IT.rc b/reactos/dll/cpl/main/lang/it-IT.rc index 82c1ea76668..89b74c90f7b 100644 --- a/reactos/dll/cpl/main/lang/it-IT.rc +++ b/reactos/dll/cpl/main/lang/it-IT.rc @@ -165,4 +165,8 @@ BEGIN IDS_SYSTEM_SCHEME "(Schema di sistema)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/ja-JP.rc b/reactos/dll/cpl/main/lang/ja-JP.rc index a0928bafce2..7fa69369b99 100644 --- a/reactos/dll/cpl/main/lang/ja-JP.rc +++ b/reactos/dll/cpl/main/lang/ja-JP.rc @@ -163,4 +163,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/nl-NL.rc b/reactos/dll/cpl/main/lang/nl-NL.rc index 6afbf56bddb..0d600769b80 100644 --- a/reactos/dll/cpl/main/lang/nl-NL.rc +++ b/reactos/dll/cpl/main/lang/nl-NL.rc @@ -162,4 +162,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/pl-PL.rc b/reactos/dll/cpl/main/lang/pl-PL.rc index c4d885bb402..7cc1b6708f5 100644 --- a/reactos/dll/cpl/main/lang/pl-PL.rc +++ b/reactos/dll/cpl/main/lang/pl-PL.rc @@ -169,4 +169,8 @@ BEGIN IDS_SYSTEM_SCHEME "(schemat systemu)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/ru-RU.rc b/reactos/dll/cpl/main/lang/ru-RU.rc index e8fd5f6678f..49b91dc5a2d 100644 --- a/reactos/dll/cpl/main/lang/ru-RU.rc +++ b/reactos/dll/cpl/main/lang/ru-RU.rc @@ -164,4 +164,8 @@ BEGIN IDS_SYSTEM_SCHEME "(system scheme)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/lang/uk-UA.rc b/reactos/dll/cpl/main/lang/uk-UA.rc index f8f4627a405..ef9a852a9a3 100644 --- a/reactos/dll/cpl/main/lang/uk-UA.rc +++ b/reactos/dll/cpl/main/lang/uk-UA.rc @@ -171,4 +171,8 @@ BEGIN IDS_SYSTEM_SCHEME "(ñèñòåìíà ñõåìà)" IDS_BROWSE_FILTER "Cursors (*.ani, *.cur)\0*.ani;*.cur\0Animated Cursors (*.ani)\0*.ani\0Static Cursors (*.cur)\0*.cur\0All Files\0*.*\0\0" IDS_BROWSE_TITLE "Browse" + IDS_REMOVE_TITLE "Confirm Scheme Removal" + IDS_REMOVE_TEXT "Are you sure you want to remove the cursor scheme '%s'?" + IDS_OVERWRITE_TITLE "Confirm Cursor Scheme Overwrite" + IDS_OVERWRITE_TEXT "The cursor scheme name you chose is already in use. Do you want to overwrite the existing cursor scheme?" END diff --git a/reactos/dll/cpl/main/mouse.c b/reactos/dll/cpl/main/mouse.c index 2e7681e6389..41beffaeaaa 100644 --- a/reactos/dll/cpl/main/mouse.c +++ b/reactos/dll/cpl/main/mouse.c @@ -568,6 +568,9 @@ static BOOL DeleteUserCursorScheme(HWND hwndDlg) { TCHAR szSchemeName[MAX_PATH]; + TCHAR szTitle[128]; + TCHAR szRawText[256]; + TCHAR szText[256]; HWND hDlgCtrl; HKEY hCuKey; HKEY hCuCursorKey; @@ -581,6 +584,15 @@ DeleteUserCursorScheme(HWND hwndDlg) SendMessage(hDlgCtrl, CB_GETLBTEXT, nSel, (LPARAM)szSchemeName); + LoadString(hApplet, IDS_REMOVE_TITLE, szTitle, 128); + LoadString(hApplet, IDS_REMOVE_TEXT, szRawText, 256); + + _stprintf(szText, szRawText, szSchemeName); + + /* Confirm scheme removal */ + if (MessageBox(hwndDlg, szText, szTitle, MB_YESNO | MB_ICONQUESTION) == IDNO) + return TRUE; + if (RegOpenCurrentUser(KEY_READ | KEY_SET_VALUE, &hCuKey) != ERROR_SUCCESS) return FALSE; @@ -646,12 +658,18 @@ SaveCursorScheme(HWND hwndDlg) { TCHAR szSystemScheme[MAX_PATH]; TCHAR szSchemeName[MAX_PATH]; + TCHAR szNewSchemeName[MAX_PATH]; + TCHAR szTitle[128]; + TCHAR szText[256]; INT nSel; INT index, i, nLength; LPTSTR lpSchemeData; HKEY hCuKey; HKEY hCuCursorKey; LONG lResult = ERROR_SUCCESS; + BOOL bSchemeExists; + + LoadString(hApplet, IDS_SYSTEM_SCHEME, szSystemScheme, MAX_PATH); nSel = SendDlgItemMessage(hwndDlg, IDC_COMBO_CURSOR_SCHEME, CB_GETCURSEL, 0, 0); if (nSel == CB_ERR) @@ -663,56 +681,84 @@ SaveCursorScheme(HWND hwndDlg) } else { - SendDlgItemMessage(hwndDlg, IDC_COMBO_CURSOR_SCHEME, CB_GETLBTEXT, nSel, (LPARAM)szSchemeName); + SendDlgItemMessage(hwndDlg, IDC_COMBO_CURSOR_SCHEME, CB_GETLBTEXT, nSel, (LPARAM)szNewSchemeName); - LoadString(hApplet, IDS_SYSTEM_SCHEME, szSystemScheme, MAX_PATH); - - if (_tcsstr(szSchemeName, szSystemScheme)) + if (_tcsstr(szNewSchemeName, szSystemScheme)) { - szSchemeName[_tcslen(szSchemeName) - _tcslen(szSystemScheme) - 1] = 0; + szNewSchemeName[_tcslen(szNewSchemeName) - _tcslen(szSystemScheme) - 1] = 0; } } - if (DialogBoxParam(hApplet, MAKEINTRESOURCE(IDD_CURSOR_SCHEME_SAVEAS), - hwndDlg, SaveSchemeProc, (LPARAM)szSchemeName)) + /* Ask for a name for the new cursor scheme */ + if (!DialogBoxParam(hApplet, MAKEINTRESOURCE(IDD_CURSOR_SCHEME_SAVEAS), + hwndDlg, SaveSchemeProc, (LPARAM)szNewSchemeName)) + return TRUE; + + /* Check all non-system schemes for the new name */ + nSel = SendDlgItemMessage(hwndDlg, IDC_COMBO_CURSOR_SCHEME, CB_GETCOUNT, 0, 0); + if (nSel == CB_ERR) + return FALSE; + + bSchemeExists = FALSE; + for (i = 0; i < nSel; i++) { - /* Save the cursor scheme */ - nLength = 0; - for (index = IDS_ARROW, i = 0; index <= IDS_HAND; index++, i++) + SendDlgItemMessage(hwndDlg, IDC_COMBO_CURSOR_SCHEME, CB_GETLBTEXT, i, (LPARAM)szSchemeName); + if (_tcsstr(szSchemeName, szSystemScheme) == NULL) { - if (i > 0) - nLength++; - nLength += _tcslen(g_CursorData[i].szCursorPath); + if (_tcscmp(szSchemeName, szNewSchemeName) == 0) + { + bSchemeExists = TRUE; + break; + } } - nLength++; - - lpSchemeData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(TCHAR)); - - for (index = IDS_ARROW, i = 0; index <= IDS_HAND; index++, i++) - { - if (i > 0) - _tcscat(lpSchemeData, _T(",")); - _tcscat(lpSchemeData, g_CursorData[i].szCursorPath); - } - - if (RegOpenCurrentUser(KEY_READ | KEY_SET_VALUE, &hCuKey) != ERROR_SUCCESS) - return FALSE; - - if (RegOpenKeyEx(hCuKey, _T("Control Panel\\Cursors\\Schemes"), 0, KEY_READ | KEY_SET_VALUE, &hCuCursorKey) != ERROR_SUCCESS) - { - RegCloseKey(hCuKey); - return FALSE; - } - - lResult = RegSetValueEx(hCuCursorKey, szSchemeName, 0, REG_EXPAND_SZ, - (LPBYTE)lpSchemeData, nLength * sizeof(TCHAR)); - - RegCloseKey(hCuCursorKey); - RegCloseKey(hCuKey); - - HeapFree(GetProcessHeap(), 0, lpSchemeData); } + if (bSchemeExists) + { + LoadString(hApplet, IDS_OVERWRITE_TITLE, szTitle, 128); + LoadString(hApplet, IDS_OVERWRITE_TEXT, szText, 256); + + /* Confirm scheme overwrite */ + if (MessageBox(hwndDlg, szText, szTitle, MB_YESNO | MB_ICONQUESTION) == IDNO) + return TRUE; + } + + /* Save the cursor scheme */ + nLength = 0; + for (index = IDS_ARROW, i = 0; index <= IDS_HAND; index++, i++) + { + if (i > 0) + nLength++; + nLength += _tcslen(g_CursorData[i].szCursorPath); + } + nLength++; + + lpSchemeData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(TCHAR)); + + for (index = IDS_ARROW, i = 0; index <= IDS_HAND; index++, i++) + { + if (i > 0) + _tcscat(lpSchemeData, _T(",")); + _tcscat(lpSchemeData, g_CursorData[i].szCursorPath); + } + + if (RegOpenCurrentUser(KEY_READ | KEY_SET_VALUE, &hCuKey) != ERROR_SUCCESS) + return FALSE; + + if (RegOpenKeyEx(hCuKey, _T("Control Panel\\Cursors\\Schemes"), 0, KEY_READ | KEY_SET_VALUE, &hCuCursorKey) != ERROR_SUCCESS) + { + RegCloseKey(hCuKey); + return FALSE; + } + + lResult = RegSetValueEx(hCuCursorKey, szNewSchemeName, 0, REG_EXPAND_SZ, + (LPBYTE)lpSchemeData, nLength * sizeof(TCHAR)); + + RegCloseKey(hCuCursorKey); + RegCloseKey(hCuKey); + + HeapFree(GetProcessHeap(), 0, lpSchemeData); + return (lResult == ERROR_SUCCESS); } diff --git a/reactos/dll/cpl/main/resource.h b/reactos/dll/cpl/main/resource.h index ed9ccbbea7e..a1f7cb8a680 100644 --- a/reactos/dll/cpl/main/resource.h +++ b/reactos/dll/cpl/main/resource.h @@ -44,7 +44,10 @@ #define IDS_SYSTEM_SCHEME 1032 #define IDS_BROWSE_FILTER 1033 #define IDS_BROWSE_TITLE 1034 - +#define IDS_REMOVE_TITLE 1035 +#define IDS_REMOVE_TEXT 1036 +#define IDS_OVERWRITE_TITLE 1037 +#define IDS_OVERWRITE_TEXT 1038 #define IDC_SWAP_MOUSE_BUTTONS 2000 #define IDC_SLIDER_DOUBLE_CLICK_SPEED 2001