regedit: Implement deleting multiple values.

This commit is contained in:
Andre Wisplinghoff 2008-07-10 14:30:27 +02:00 committed by Alexandre Julliard
parent e4078fb0ba
commit a7f84cc035
8 changed files with 34 additions and 9 deletions

View File

@ -299,6 +299,7 @@ BEGIN
IDS_TOO_BIG_VALUE "Der Wert ist zu groß (%ld)"
IDS_DELETE_BOX_TITLE "Bitte bestätigen"
IDS_DELETE_BOX_TEXT "Wollen Sie '%s' wirklich löschen?"
IDS_DELETE_BOX_TEXT_MULTIPLE "Wollen Sie diese Werte wirklich löschen?"
IDS_NEWKEY "Neuer Schlüssel #%d"
IDS_NEWVALUE "Neuer Wert #%d"
IDS_NOTFOUND "Suchfolge '%s' wurde nicht gefunden."

View File

@ -371,6 +371,7 @@ BEGIN
IDS_TOO_BIG_VALUE "Value is too big (%ld)"
IDS_DELETE_BOX_TITLE "Confirm Value Delete"
IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?"
IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?"
IDS_NEWKEY "New Key #%d"
IDS_NEWVALUE "New Value #%d"
IDS_NOTFOUND "Search string '%s' not found"

View File

@ -294,6 +294,7 @@ BEGIN
IDS_TOO_BIG_VALUE "La valeur est trop grande (%ld)"
IDS_DELETE_BOX_TITLE "Confirmez l'effacement de valeur"
IDS_DELETE_BOX_TEXT "Êtes vous sûr vous voulez supprimer la valeur '%s'?"
IDS_DELETE_BOX_TEXT_MULTIPLE "Êtes vous sûr vous voulez supprimer cette valeurs?"
IDS_NEWKEY "Nouvelle Clé #%d"
IDS_NEWVALUE "Nouvelle Valeur #%d"
IDS_NOTFOUND "Occurence de '%s' non trouvée"

View File

@ -413,7 +413,7 @@ done:
return result;
}
BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName, BOOL showMessageBox)
{
BOOL result = FALSE;
LONG lRet;
@ -423,8 +423,9 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_READ | KEY_SET_VALUE, &hKey);
if (lRet != ERROR_SUCCESS) return FALSE;
if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, visibleValueName) != IDYES)
goto done;
if (showMessageBox)
if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, visibleValueName) != IDYES)
goto done;
lRet = RegDeleteValue(hKey, valueName ? valueName : "");
if (lRet != ERROR_SUCCESS && valueName) {

View File

@ -629,9 +629,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LPCTSTR valueName;
TCHAR newKey[MAX_NEW_KEY_LEN];
DWORD valueType;
int curIndex;
BOOL firstItem = TRUE;
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
valueName = GetValueName(g_pChildWnd->hListWnd);
if (LOWORD(wParam) >= ID_FAVORITE_FIRST && LOWORD(wParam) <= ID_FAVORITE_LAST) {
HKEY hKey;
@ -674,11 +675,29 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DeleteNode(g_pChildWnd->hTreeWnd, 0);
}
} else if (GetFocus() == g_pChildWnd->hListWnd) {
if (DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
curIndex = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_SELECTED);
while(curIndex != -1) {
valueName = GetItemText(g_pChildWnd->hListWnd, curIndex);
curIndex = ListView_GetNextItem(g_pChildWnd->hListWnd, curIndex, LVNI_SELECTED);
if(curIndex != -1 && firstItem) {
TCHAR title[256];
TCHAR text[1024];
if(!LoadString(hInst, IDS_DELETE_BOX_TITLE, title, COUNT_OF(title)))
lstrcpy(title, "Error");
if(!LoadString(hInst, IDS_DELETE_BOX_TEXT_MULTIPLE, text, COUNT_OF(text)))
lstrcpy(text, "Unknown error string!");
if (MessageBox(hWnd, text, title, MB_YESNO | MB_ICONEXCLAMATION) != IDYES)
break;
}
if (!DeleteValue(hWnd, hKeyRoot, keyPath, valueName, curIndex==-1 && firstItem))
break;
firstItem = FALSE;
}
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL);
}
break;
case ID_EDIT_MODIFY:
valueName = GetValueName(g_pChildWnd->hListWnd);
if (ModifyValue(hWnd, hKeyRoot, keyPath, valueName))
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, valueName);
break;

View File

@ -54,7 +54,7 @@ static TCHAR g_szValueNotSet[64];
static int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 };
static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT };
static LPTSTR get_item_text(HWND hwndLV, int item)
LPTSTR GetItemText(HWND hwndLV, UINT item)
{
LPTSTR newStr, curStr;
unsigned int maxLen = 128;
@ -88,7 +88,7 @@ LPCTSTR GetValueName(HWND hwndLV)
item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED);
if (item == -1) return NULL;
g_valueName = get_item_text(hwndLV, item);
g_valueName = GetItemText(hwndLV, item);
return g_valueName;
}
@ -391,7 +391,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
break;
case LVN_ENDLABELEDIT: {
LPNMLVDISPINFO dispInfo = (LPNMLVDISPINFO)lParam;
LPTSTR valueName = get_item_text(hWnd, dispInfo->item.iItem);
LPTSTR valueName = GetItemText(hWnd, dispInfo->item.iItem);
LONG ret;
if (!valueName) return -1; /* cannot rename a default value */
ret = RenameValue(hWnd, g_currentRootKey, g_currentPath, valueName, dispInfo->item.pszText);

View File

@ -109,6 +109,7 @@ extern void UpdateStatusBar(void);
extern HWND CreateListView(HWND hwndParent, UINT id);
extern BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR highlightValue);
extern HWND StartValueRename(HWND hwndLV);
extern LPTSTR GetItemText(HWND hwndLV, UINT item);
extern LPCTSTR GetValueName(HWND hwndLV);
extern BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result);
extern BOOL IsDefaultValue(HWND hwndLV, int i);
@ -129,7 +130,7 @@ extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPTSTR newKeyNa
extern BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, DWORD valueType, LPTSTR valueName);
extern BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath);
extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName, BOOL showMessageBox);
extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR oldName, LPCTSTR newName);
extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName);
extern void error(HWND hwnd, INT resId, ...);

View File

@ -121,6 +121,7 @@
#define IDS_DELETE_BOX_TITLE 32840
#define IDS_DELETE_BOX_TEXT 32841
#define IDS_NOTFOUND 32842
#define IDS_DELETE_BOX_TEXT_MULTIPLE 32843
#define IDD_EDIT_DWORD 32850
#define IDC_DWORD_BASE 32852
#define IDC_DWORD_HEX 32853