diff --git a/reactos/dll/cpl/sysdm/hardprof.c b/reactos/dll/cpl/sysdm/hardprof.c index b5e67dfbd27..6ef7ec2a4c3 100644 --- a/reactos/dll/cpl/sysdm/hardprof.c +++ b/reactos/dll/cpl/sysdm/hardprof.c @@ -34,16 +34,39 @@ typedef struct _PROFILENAMES { WCHAR szSourceName[PROFILE_NAME_LENGTH]; WCHAR szDestinationName[PROFILE_NAME_LENGTH]; + PPROFILEDATA pProfileData; } PROFILENAMES, *PPROFILENAMES; +static +BOOL +IsProfileNameInUse( + PPROFILENAMES pProfileNames, + BOOL bIgnoreCurrent) +{ + DWORD i; + + for (i = 0; i < pProfileNames->pProfileData->dwProfileCount; i++) + { + if (bIgnoreCurrent == TRUE && i == pProfileNames->pProfileData->dwSelectedProfileIndex) + continue; + + if (wcscmp(pProfileNames->pProfileData->pProfiles[i].szFriendlyName, pProfileNames->szDestinationName) == 0) + return TRUE; + } + + return FALSE; +} + + static INT_PTR CALLBACK -CopyProfileDlgProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) +CopyProfileDlgProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { PPROFILENAMES pProfileNames; @@ -71,7 +94,14 @@ CopyProfileDlgProc(HWND hwndDlg, IDC_COPYPROFILETO, pProfileNames->szDestinationName, PROFILE_NAME_LENGTH); - EndDialog(hwndDlg, IDOK); + if (IsProfileNameInUse(pProfileNames, FALSE)) + ResourceMessageBox(hApplet, + NULL, + MB_OK | MB_ICONERROR, + IDS_HWPROFILE_WARNING, + IDS_HWPROFILE_ALREADY_IN_USE); + else + EndDialog(hwndDlg, IDOK); return TRUE; case IDCANCEL: @@ -102,6 +132,8 @@ CopyHardwareProfile( wcscpy(ProfileNames.szSourceName, pProfile->szFriendlyName); swprintf(ProfileNames.szDestinationName, L"%s %lu", szBuffer, pProfileData->dwProfileCount); + ProfileNames.pProfileData = pProfileData; + if (DialogBoxParam(hApplet, MAKEINTRESOURCE(IDD_COPYPROFILE), hwndDlg, @@ -145,10 +177,11 @@ CopyHardwareProfile( static INT_PTR CALLBACK -RenameProfileDlgProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) +RenameProfileDlgProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { PPROFILENAMES pProfileNames; @@ -176,7 +209,14 @@ RenameProfileDlgProc(HWND hwndDlg, IDC_RENPROFEDITTO, pProfileNames->szDestinationName, PROFILE_NAME_LENGTH); - EndDialog(hwndDlg, IDOK); + if (IsProfileNameInUse(pProfileNames, TRUE)) + ResourceMessageBox(hApplet, + NULL, + MB_OK | MB_ICONERROR, + IDS_HWPROFILE_WARNING, + IDS_HWPROFILE_ALREADY_IN_USE); + else + EndDialog(hwndDlg, IDOK); return TRUE; case IDCANCEL: @@ -207,6 +247,8 @@ RenameHardwareProfile( wcscpy(ProfileNames.szSourceName, pProfile->szFriendlyName); swprintf(ProfileNames.szDestinationName, L"%s %lu", szBuffer, pProfileData->dwProfileCount); + ProfileNames.pProfileData = pProfileData; + if (DialogBoxParam(hApplet, MAKEINTRESOURCE(IDD_RENAMEPROFILE), hwndDlg, @@ -248,36 +290,36 @@ DeleteHardwareProfile( if (MessageBox(NULL, szMessage, szCaption, - MB_YESNO | MB_ICONQUESTION) == IDYES) + MB_YESNO | MB_ICONQUESTION) != IDYES) + return; + + SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, pProfileData->dwSelectedProfileIndex, 0); + + if (pProfileData->dwSelectedProfileIndex != pProfileData->dwProfileCount - 1) { - SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, pProfileData->dwSelectedProfileIndex, 0); - - if (pProfileData->dwSelectedProfileIndex != pProfileData->dwProfileCount - 1) - { - RtlMoveMemory(&pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex], - &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex + 1], - (pProfileData->dwProfileCount - pProfileData->dwSelectedProfileIndex - 1) * sizeof(PPROFILE)); - } - else - { - pProfileData->dwSelectedProfileIndex--; - } - - pProfiles = HeapReAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - pProfileData->pProfiles, - (pProfileData->dwProfileCount - 1) * sizeof(PROFILE)); - if (pProfiles == NULL) - { - DPRINT1("HeapReAlloc() failed!\n"); - return; - } - - pProfileData->dwProfileCount--; - pProfileData->pProfiles = pProfiles; - - SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_SETCURSEL, pProfileData->dwSelectedProfileIndex, 0); + RtlMoveMemory(&pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex], + &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex + 1], + (pProfileData->dwProfileCount - pProfileData->dwSelectedProfileIndex - 1) * sizeof(PPROFILE)); } + else + { + pProfileData->dwSelectedProfileIndex--; + } + + pProfiles = HeapReAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + pProfileData->pProfiles, + (pProfileData->dwProfileCount - 1) * sizeof(PROFILE)); + if (pProfiles == NULL) + { + DPRINT1("HeapReAlloc() failed!\n"); + return; + } + + pProfileData->dwProfileCount--; + pProfileData->pProfiles = pProfiles; + + SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_SETCURSEL, pProfileData->dwSelectedProfileIndex, 0); } diff --git a/reactos/dll/cpl/sysdm/lang/bg-BG.rc b/reactos/dll/cpl/sysdm/lang/bg-BG.rc index c68104669fb..f24fba8e7d2 100644 --- a/reactos/dll/cpl/sysdm/lang/bg-BG.rc +++ b/reactos/dll/cpl/sysdm/lang/bg-BG.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/cs-CZ.rc b/reactos/dll/cpl/sysdm/lang/cs-CZ.rc index abe39f2b0ca..d7891ce63c9 100644 --- a/reactos/dll/cpl/sysdm/lang/cs-CZ.rc +++ b/reactos/dll/cpl/sysdm/lang/cs-CZ.rc @@ -288,4 +288,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/da-DK.rc b/reactos/dll/cpl/sysdm/lang/da-DK.rc index 5e5b6364b4b..a9451e7182b 100644 --- a/reactos/dll/cpl/sysdm/lang/da-DK.rc +++ b/reactos/dll/cpl/sysdm/lang/da-DK.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/de-DE.rc b/reactos/dll/cpl/sysdm/lang/de-DE.rc index 367982f8676..00a11c65103 100644 --- a/reactos/dll/cpl/sysdm/lang/de-DE.rc +++ b/reactos/dll/cpl/sysdm/lang/de-DE.rc @@ -292,4 +292,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/el-GR.rc b/reactos/dll/cpl/sysdm/lang/el-GR.rc index 79a6db7b2e0..21b4543365d 100644 --- a/reactos/dll/cpl/sysdm/lang/el-GR.rc +++ b/reactos/dll/cpl/sysdm/lang/el-GR.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/en-US.rc b/reactos/dll/cpl/sysdm/lang/en-US.rc index 2eeef29d54c..6d1528f7079 100644 --- a/reactos/dll/cpl/sysdm/lang/en-US.rc +++ b/reactos/dll/cpl/sysdm/lang/en-US.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/es-ES.rc b/reactos/dll/cpl/sysdm/lang/es-ES.rc index d68bbde3383..b83d476981d 100644 --- a/reactos/dll/cpl/sysdm/lang/es-ES.rc +++ b/reactos/dll/cpl/sysdm/lang/es-ES.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/fr-FR.rc b/reactos/dll/cpl/sysdm/lang/fr-FR.rc index ff1b7756297..3c9e7c5a2a1 100644 --- a/reactos/dll/cpl/sysdm/lang/fr-FR.rc +++ b/reactos/dll/cpl/sysdm/lang/fr-FR.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/he-IL.rc b/reactos/dll/cpl/sysdm/lang/he-IL.rc index 812043a8915..fe5ae32710a 100644 --- a/reactos/dll/cpl/sysdm/lang/he-IL.rc +++ b/reactos/dll/cpl/sysdm/lang/he-IL.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/hu-HU.rc b/reactos/dll/cpl/sysdm/lang/hu-HU.rc index c60ba6c9205..710a66be036 100644 --- a/reactos/dll/cpl/sysdm/lang/hu-HU.rc +++ b/reactos/dll/cpl/sysdm/lang/hu-HU.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/id-ID.rc b/reactos/dll/cpl/sysdm/lang/id-ID.rc index 0cb3447f38e..551218def62 100644 --- a/reactos/dll/cpl/sysdm/lang/id-ID.rc +++ b/reactos/dll/cpl/sysdm/lang/id-ID.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/it-IT.rc b/reactos/dll/cpl/sysdm/lang/it-IT.rc index 9887db5ee34..6e50444d1a1 100644 --- a/reactos/dll/cpl/sysdm/lang/it-IT.rc +++ b/reactos/dll/cpl/sysdm/lang/it-IT.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/ja-JP.rc b/reactos/dll/cpl/sysdm/lang/ja-JP.rc index 5ad79e14588..97fc4827f3b 100644 --- a/reactos/dll/cpl/sysdm/lang/ja-JP.rc +++ b/reactos/dll/cpl/sysdm/lang/ja-JP.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/nl-NL.rc b/reactos/dll/cpl/sysdm/lang/nl-NL.rc index ad2babae336..981f057de12 100644 --- a/reactos/dll/cpl/sysdm/lang/nl-NL.rc +++ b/reactos/dll/cpl/sysdm/lang/nl-NL.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/no-NO.rc b/reactos/dll/cpl/sysdm/lang/no-NO.rc index a9443a84c45..34550d767c0 100644 --- a/reactos/dll/cpl/sysdm/lang/no-NO.rc +++ b/reactos/dll/cpl/sysdm/lang/no-NO.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/pl-PL.rc b/reactos/dll/cpl/sysdm/lang/pl-PL.rc index 8104529fe09..57dd0c2d748 100644 --- a/reactos/dll/cpl/sysdm/lang/pl-PL.rc +++ b/reactos/dll/cpl/sysdm/lang/pl-PL.rc @@ -292,4 +292,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/ro-RO.rc b/reactos/dll/cpl/sysdm/lang/ro-RO.rc index fde1c7a1db4..9791ea53ecd 100644 --- a/reactos/dll/cpl/sysdm/lang/ro-RO.rc +++ b/reactos/dll/cpl/sysdm/lang/ro-RO.rc @@ -292,4 +292,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/ru-RU.rc b/reactos/dll/cpl/sysdm/lang/ru-RU.rc index 46abe9fc7c5..d64319b0240 100644 --- a/reactos/dll/cpl/sysdm/lang/ru-RU.rc +++ b/reactos/dll/cpl/sysdm/lang/ru-RU.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/sk-SK.rc b/reactos/dll/cpl/sysdm/lang/sk-SK.rc index 04eac0c5fee..658b8ebad25 100644 --- a/reactos/dll/cpl/sysdm/lang/sk-SK.rc +++ b/reactos/dll/cpl/sysdm/lang/sk-SK.rc @@ -291,4 +291,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/sq-AL.rc b/reactos/dll/cpl/sysdm/lang/sq-AL.rc index 4e253a2c994..0fca361211e 100644 --- a/reactos/dll/cpl/sysdm/lang/sq-AL.rc +++ b/reactos/dll/cpl/sysdm/lang/sq-AL.rc @@ -283,4 +283,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/sv-SE.rc b/reactos/dll/cpl/sysdm/lang/sv-SE.rc index 4a6e7246f7a..17046ec8b0d 100644 --- a/reactos/dll/cpl/sysdm/lang/sv-SE.rc +++ b/reactos/dll/cpl/sysdm/lang/sv-SE.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/tr-TR.rc b/reactos/dll/cpl/sysdm/lang/tr-TR.rc index 10e223430b0..6a2a3c138d8 100644 --- a/reactos/dll/cpl/sysdm/lang/tr-TR.rc +++ b/reactos/dll/cpl/sysdm/lang/tr-TR.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/uk-UA.rc b/reactos/dll/cpl/sysdm/lang/uk-UA.rc index 7d4b178cdae..d1732f8c612 100644 --- a/reactos/dll/cpl/sysdm/lang/uk-UA.rc +++ b/reactos/dll/cpl/sysdm/lang/uk-UA.rc @@ -291,4 +291,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/lang/zh-CN.rc b/reactos/dll/cpl/sysdm/lang/zh-CN.rc index fe0996da4bd..6baff330459 100644 --- a/reactos/dll/cpl/sysdm/lang/zh-CN.rc +++ b/reactos/dll/cpl/sysdm/lang/zh-CN.rc @@ -285,4 +285,5 @@ BEGIN IDS_HWPROFILE_CONFIRM_DELETE "Are you sure you want to delete the hardware profile ""%s""?" IDS_HWPROFILE_ALREADY_IN_USE "The profile name is already in use." IDS_HWPROFILE_PROFILE "Profile" + IDS_HWPROFILE_WARNING "Warning" END diff --git a/reactos/dll/cpl/sysdm/resource.h b/reactos/dll/cpl/sysdm/resource.h index e70ce649913..5095a648a09 100644 --- a/reactos/dll/cpl/sysdm/resource.h +++ b/reactos/dll/cpl/sysdm/resource.h @@ -47,6 +47,7 @@ #define IDS_HWPROFILE_CONFIRM_DELETE 86 #define IDS_HWPROFILE_ALREADY_IN_USE 87 #define IDS_HWPROFILE_PROFILE 88 +#define IDS_HWPROFILE_WARNING 89 /* Propsheet - general */ #define IDD_PROPPAGEGENERAL 100