- Copy key name works.

- Favorites (adding, removing, going to) work.
- Added context sensitive graying to some menu options.
- Cleanup of status bar update.
This commit is contained in:
Krzysztof Foltman 2005-09-26 09:57:56 +00:00 committed by Alexandre Julliard
parent baab789ce8
commit 83edf20502
9 changed files with 396 additions and 51 deletions

View File

@ -74,9 +74,7 @@ BEGIN
POPUP "&Favourites"
BEGIN
MENUITEM "&Add to Favourites", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Remove Favourite", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "&Help"
BEGIN
@ -152,9 +150,7 @@ BEGIN
POPUP "&Favorites"
BEGIN
MENUITEM "&Add to Favorites", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Remove Favorite", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "&Help"
BEGIN
@ -211,13 +207,35 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
END
IDD_ADDFAVORITE DIALOG DISCARDABLE 22, 17, 210, 55
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Add Favorite"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Name:",IDC_STATIC,5,5,119,8
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,140,40,30,11,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,175,40,30,11, WS_GROUP
END
IDD_DELFAVORITE DIALOG DISCARDABLE 22, 17, 210, 90
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Remove Favorite"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Name:",IDC_STATIC,5,5,119,8
LISTBOX IDC_NAME_LIST,5,15,200,52, WS_BORDER | WS_TABSTOP | LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL
DEFPUSHBUTTON "OK",IDOK,140,73,30,11,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,175,73,30,11, WS_GROUP
END
IDD_EDIT_STRING DIALOG DISCARDABLE 22, 17, 210, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Edit String"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Value name:",IDC_STATIC,5,5,119,8
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | WS_DISABLED
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL| WS_DISABLED
LTEXT "Value data:",IDC_STATIC,5,30,119,8
EDITTEXT IDC_VALUE_DATA,5,40,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,140,60,30,11,WS_GROUP
@ -230,7 +248,7 @@ CAPTION "Edit DWORD"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Value name:",IDC_STATIC,5,5,119,8
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | WS_DISABLED
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL| WS_DISABLED
LTEXT "Value data:",IDC_STATIC,5,30,90,8
EDITTEXT IDC_VALUE_DATA,5,40,90,12, WS_BORDER | WS_TABSTOP
GROUPBOX "Base", IDC_DWORD_BASE, 120, 30, 85, 37, BS_GROUPBOX
@ -246,7 +264,7 @@ CAPTION "Edit Binary"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Value name:",IDC_STATIC,5,5,119,8
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | WS_DISABLED
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL| WS_DISABLED
LTEXT "Value data:",IDC_STATIC,5,30,90,8
CONTROL "",IDC_VALUE_DATA,"HexEdit",WS_TABSTOP,4,40,160,40
DEFPUSHBUTTON "OK",IDOK,140,80,30,11,WS_GROUP

View File

@ -82,9 +82,7 @@ BEGIN
POPUP "&Favorieten"
BEGIN
MENUITEM "&Toevoegen aan favorieten", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Verwijderen uit favorieten", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "&Help"
BEGIN

View File

@ -82,9 +82,7 @@ BEGIN
POPUP "&Ulubione"
BEGIN
MENUITEM "&Dodaj do ulubionych", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Usuñ ulubiony", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "Pomo&c"
BEGIN
@ -141,6 +139,28 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
END
IDD_ADDFAVORITE DIALOG DISCARDABLE 22, 17, 210, 55
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Dodaj do ulubionych"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Nazwa:",IDC_STATIC,5,5,119,8
EDITTEXT IDC_VALUE_NAME,5,15,200,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,140,40,30,11,WS_GROUP
PUSHBUTTON "Anuluj",IDCANCEL,175,40,30,11, WS_GROUP
END
IDD_DELFAVORITE DIALOG DISCARDABLE 22, 17, 210, 90
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Usuñ ulubiony"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Nazwa:",IDC_STATIC,5,5,119,8
LISTBOX IDC_NAME_LIST,5,15,200,52, WS_BORDER | WS_TABSTOP | LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL
DEFPUSHBUTTON "OK",IDOK,140,73,30,11,WS_GROUP
PUSHBUTTON "Anuluj",IDCANCEL,175,73,30,11, WS_GROUP
END
IDD_EDIT_STRING DIALOG DISCARDABLE 22, 17, 210, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "Edycja danej tekstowej"

View File

@ -100,9 +100,7 @@ BEGIN
POPUP "&Favoritos"
BEGIN
MENUITEM "&Adicionar aos Favoritos", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Remover Favorito", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "Aj&uda"
BEGIN
@ -160,9 +158,7 @@ BEGIN
POPUP "&Favoritos"
BEGIN
MENUITEM "&Adicionar aos Favoritos", ID_FAVORITES_ADDTOFAVORITES
, GRAYED
MENUITEM "&Remover Favorito", ID_FAVORITES_REMOVEFAVORITE
, GRAYED
END
POPUP "Aj&uda"
BEGIN

View File

@ -37,7 +37,7 @@ ChildWnd* g_pChildWnd;
* Local module support methods
*/
static LPCTSTR get_root_key_name(HKEY hRootKey)
LPCTSTR GetRootKeyName(HKEY hRootKey)
{
if (hRootKey == HKEY_CLASSES_ROOT) return _T("HKEY_CLASSES_ROOT");
if (hRootKey == HKEY_CURRENT_USER) return _T("HKEY_CURRENT_USER");
@ -45,7 +45,7 @@ static LPCTSTR get_root_key_name(HKEY hRootKey)
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
return _T("UKNOWN HKEY, PLEASE REPORT");
return _T("UNKNOWN HKEY, PLEASE REPORT");
}
static void draw_splitbar(HWND hWnd, int x)
@ -83,33 +83,61 @@ static void OnPaint(HWND hWnd)
EndPaint(hWnd, &ps);
}
void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV)
{
LPCTSTR keyPath, rootName;
LPTSTR fullPath;
HKEY hRootKey;
keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
if (keyPath) {
if (bRefreshLV)
RefreshListView(hwndLV, hRootKey, keyPath, NULL);
rootName = get_root_key_name(hRootKey);
fullPath = HeapAlloc(GetProcessHeap(), 0, (lstrlen(rootName) + 1 + lstrlen(keyPath) + 1) * sizeof(TCHAR));
if (fullPath) {
_stprintf(fullPath, "%s\\%s", rootName, keyPath);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
HeapFree(GetProcessHeap(), 0, fullPath);
static LPTSTR CombinePaths(LPCTSTR pPaths[], int nPaths) {
int i, len, pos;
LPTSTR combined;
for (i=0, len=0; i<nPaths; i++) {
if (pPaths[i] && *pPaths[i]) {
len += lstrlen(pPaths[i])+1;
}
}
else {
/* else the computer icon is being selected, so display computer name */
TCHAR text[260];
DWORD size;
size = sizeof(text)/sizeof(TCHAR);
GetComputerName(text, &size);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
combined = HeapAlloc(GetProcessHeap(), 0, len * sizeof(TCHAR));
*combined = '\0';
for (i=0, pos=0; i<nPaths; i++) {
if (pPaths[i] && *pPaths[i]) {
int llen = _tcslen(pPaths[i]);
if (!*combined)
_tcscpy(combined, pPaths[i]);
else {
combined[pos++] = (TCHAR)'\\';
_tcscpy(combined+pos, pPaths[i]);
}
pos += llen;
}
}
return combined;
}
LPTSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
LPCTSTR parts[3] = {_T(""), _T(""), _T("")};
TCHAR text[260];
HKEY hRootKey = NULL;
if (!hItem)
hItem = TreeView_GetSelection(hwndTV);
parts[2] = GetItemPath(hwndTV, hItem, &hRootKey);
if (!parts[2])
parts[2] = _T("");
if (!bFull && !hRootKey && !*parts[2])
return NULL;
if (hRootKey)
parts[1] = GetRootKeyName(hRootKey);
if (bFull) {
DWORD dwSize = sizeof(text)/sizeof(TCHAR);
GetComputerName(text, &dwSize);
parts[0] = text;
}
return CombinePaths(parts, 3);
}
static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV)
{
if (bRefreshLV) {
LPCTSTR keyPath;
HKEY hRootKey = NULL;
keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
RefreshListView(hwndLV, hRootKey, keyPath, NULL);
}
UpdateStatusBar();
}
/*******************************************************************************

View File

@ -36,7 +36,9 @@
* Global and Local Variables:
*/
static TCHAR favoritesKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\RegEdit\\Favorites");
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
static TCHAR favoriteName[128];
/*******************************************************************************
* Local module support methods
@ -90,6 +92,58 @@ static void OnExitMenuLoop(HWND hWnd)
UpdateStatusBar();
}
static void UpdateMenuItems(HMENU hMenu) {
HWND hwndTV = g_pChildWnd->hTreeWnd;
BOOL bIsKeySelected = FALSE;
HKEY hRootKey = NULL;
LPCTSTR keyName;
keyName = GetItemPath(hwndTV, TreeView_GetSelection(hwndTV), &hRootKey);
if (keyName && *keyName) { /* can't modify root keys */
bIsKeySelected = TRUE;
}
EnableMenuItem(hMenu, ID_EDIT_MODIFY, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_EDIT_DELETE, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_EDIT_RENAME, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_FAVORITES_ADDTOFAVORITES, (hRootKey ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE,
(GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
}
static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
{
if (wItem == 3) {
HKEY hKey;
while(GetMenuItemCount(hMenu)>2)
DeleteMenu(hMenu, 2, MF_BYPOSITION);
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096];
int i = 0;
BOOL sep = FALSE;
DWORD ksize, vsize, type;
LONG error;
do {
ksize = KEY_MAX_LEN;
vsize = sizeof(valuebuf);
error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
if (error != ERROR_SUCCESS)
break;
if (type == REG_SZ) {
if (!sep) {
AppendMenu(hMenu, MF_SEPARATOR, -1, NULL);
sep = TRUE;
}
AppendMenu(hMenu, MF_STRING, ID_FAVORITE_FIRST+i, namebuf);
}
i++;
} while(error == ERROR_SUCCESS);
RegCloseKey(hKey);
}
}
UpdateMenuItems(hMenu);
}
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
TCHAR str[100];
@ -126,11 +180,9 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
void UpdateStatusBar(void)
{
/* real updating of status bar happens in the treeview selection
* change handler, so fake a selection change to it, but don't
* refresh the listview or the current selection will change */
OnTreeSelectionChanged(g_pChildWnd->hTreeWnd, g_pChildWnd->hListWnd,
TreeView_GetSelection(g_pChildWnd->hTreeWnd), FALSE);
LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
HeapFree(GetProcessHeap(), 0, fullPath);
}
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
@ -392,9 +444,12 @@ static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
if (result) {
result = EmptyClipboard();
if (result) {
/*HANDLE hClipData;*/
/*hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);*/
int len = (_tcslen(keyName)+1)*sizeof(TCHAR);
HANDLE hClipData = GlobalAlloc(GHND, len);
LPVOID pLoc = GlobalLock(hClipData);
_tcscpy(pLoc, keyName);
GlobalUnlock(hClipData);
hClipData = SetClipboardData(CF_TEXT, hClipData);
} else {
/* error emptying clipboard*/
@ -414,6 +469,103 @@ static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
return result;
}
static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_NAME);
switch(uMsg) {
case WM_INITDIALOG:
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_VALUE_NAME:
if (HIWORD(wParam) == EN_UPDATE) {
EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(hwndValue)>0);
return TRUE;
}
break;
case IDOK:
if (GetWindowTextLength(hwndValue)>0) {
GetWindowText(hwndValue, favoriteName, 128);
EndDialog(hwndDlg, IDOK);
}
return TRUE;
case IDCANCEL:
EndDialog(hwndDlg, IDCANCEL);
return TRUE;
}
break;
}
return FALSE;
}
static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_NAME_LIST);
switch(uMsg) {
case WM_INITDIALOG: {
HKEY hKey;
int i = 0;
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096];
DWORD ksize, vsize, type;
LONG error;
do {
ksize = KEY_MAX_LEN;
vsize = sizeof(valuebuf);
error = RegEnumValue(hKey, i, namebuf, &ksize, NULL, &type, valuebuf, &vsize);
if (error != ERROR_SUCCESS)
break;
if (type == REG_SZ) {
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)namebuf);
}
i++;
} while(error == ERROR_SUCCESS);
RegCloseKey(hKey);
}
else
return FALSE;
EnableWindow(GetDlgItem(hwndDlg, IDOK), i != 0);
SendMessage(hwndList, LB_SETCURSEL, 0, 0);
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_NAME_LIST:
if (HIWORD(wParam) == LBN_SELCHANGE) {
EnableWindow(GetDlgItem(hwndDlg, IDOK), lParam != -1);
return TRUE;
}
break;
case IDOK: {
int pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
int len = SendMessage(hwndList, LB_GETTEXTLEN, pos, 0);
if (len>0) {
LPTSTR lpName = HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*(len+1));
SendMessage(hwndList, LB_GETTEXT, pos, (LPARAM)lpName);
if (len>127)
lpName[127] = '\0';
_tcscpy(favoriteName, lpName);
EndDialog(hwndDlg, IDOK);
HeapFree(GetProcessHeap(), 0, lpName);
}
return TRUE;
}
case IDCANCEL:
EndDialog(hwndDlg, IDCANCEL);
return TRUE;
}
break;
}
return FALSE;
}
/*******************************************************************************
*
* FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
@ -432,6 +584,22 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
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;
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
TCHAR namebuf[KEY_MAX_LEN];
BYTE valuebuf[4096];
DWORD ksize = KEY_MAX_LEN, vsize = sizeof(valuebuf), type = 0;
if (RegEnumValue(hKey, LOWORD(wParam) - ID_FAVORITE_FIRST, namebuf, &ksize, NULL,
&type, valuebuf, &vsize) == ERROR_SUCCESS) {
TreeView_SelectItem(g_pChildWnd->hTreeWnd,
FindPathInTree(g_pChildWnd->hTreeWnd, (TCHAR *)valuebuf));
}
RegCloseKey(hKey);
}
return TRUE;
}
switch (LOWORD(wParam)) {
case ID_REGISTRY_IMPORTREGISTRYFILE:
ImportRegistryFile(hWnd);
@ -463,8 +631,14 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, valueName);
break;
case ID_EDIT_COPYKEYNAME:
CopyKeyName(hWnd, _T(""));
{
LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
if (fullPath) {
CopyKeyName(hWnd, fullPath);
HeapFree(GetProcessHeap(), 0, fullPath);
}
break;
}
case ID_EDIT_NEW_KEY:
if (CreateKey(hWnd, hKeyRoot, keyPath, newKey)) {
if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKey))
@ -508,6 +682,35 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_REGISTRY_EXIT:
DestroyWindow(hWnd);
break;
case ID_FAVORITES_ADDTOFAVORITES:
{
HKEY hKey;
LPTSTR lpKeyPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
if (lpKeyPath) {
if (DialogBox(0, MAKEINTRESOURCE(IDD_ADDFAVORITE), hWnd, addtofavorites_dlgproc) == IDOK) {
if (RegCreateKeyEx(HKEY_CURRENT_USER, favoritesKey,
0, NULL, 0,
KEY_READ|KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueEx(hKey, favoriteName, 0, REG_SZ, (BYTE *)lpKeyPath, (_tcslen(lpKeyPath)+1)*sizeof(TCHAR));
RegCloseKey(hKey);
}
}
HeapFree(GetProcessHeap(), 0, lpKeyPath);
}
break;
}
case ID_FAVORITES_REMOVEFAVORITE:
{
if (DialogBox(0, MAKEINTRESOURCE(IDD_DELFAVORITE), hWnd, removefavorite_dlgproc) == IDOK) {
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, favoritesKey,
0, KEY_READ|KEY_WRITE, &hKey) == ERROR_SUCCESS) {
RegDeleteValue(hKey, favoriteName);
RegCloseKey(hKey);
}
}
break;
}
case ID_VIEW_REFRESH:
RefreshTreeView(g_pChildWnd->hTreeWnd);
/*RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); */
@ -583,6 +786,10 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_EXITMENULOOP:
OnExitMenuLoop(hWnd);
break;
case WM_INITMENUPOPUP:
if (!HIWORD(lParam))
OnInitMenuPopup(hWnd, (HMENU)wParam, LOWORD(lParam));
break;
case WM_MENUSELECT:
OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
break;

View File

@ -89,6 +89,8 @@ extern LPCTSTR g_pszDefaultValueName;
extern void ShowAboutBox(HWND hWnd);
/* childwnd.c */
extern LPCTSTR GetRootKeyName(HKEY hRootKey);
extern LPTSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull);
extern LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
/* framewnd.c */
@ -108,11 +110,11 @@ extern BOOL IsDefaultValue(HWND hwndLV, int i);
extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
extern BOOL RefreshTreeView(HWND hWndTV);
extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
extern void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV);
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
extern BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem);
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name);
extern HWND StartKeyRename(HWND hwndTV);
extern HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName);
/* edit.c */
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPTSTR newKeyName);

View File

@ -40,7 +40,9 @@
#define IDI_OPEN_FILE 132
#define IDD_DIALOG2 132
#define IDI_CLOSED_FILE 133
#define IDD_ADDFAVORITE 133
#define IDI_ROOT 134
#define IDD_DELFAVORITE 134
#define IDI_STRING 135
#define IDI_BIN 136
#define IDR_POPUP_MENUS 137
@ -120,10 +122,13 @@
#define IDS_BAD_KEY 32862
#define ID_EDIT_MODIFY_BIN 32870
#define ID_SWITCH_PANELS 32871
#define ID_FAVORITE_FIRST 33000
#define ID_FAVORITE_LAST 33099
#define IDD_EDIT_STRING 2000
#define IDC_VALUE_NAME 2001
#define IDC_VALUE_DATA 2002
#define IDD_EDIT_BINARY 2003
#define IDC_NAME_LIST 2004
#define IDC_STATIC -1

View File

@ -104,6 +104,77 @@ LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
return pathBuffer;
}
static LPTSTR get_path_component(LPCTSTR *lplpKeyName) {
LPCTSTR lpPos = *lplpKeyName;
LPTSTR lpResult = NULL;
int len;
if (!lpPos)
return NULL;
while(*lpPos && *lpPos != '\\')
lpPos++;
if (*lpPos && lpPos == *lplpKeyName)
return NULL;
len = (lpPos+1-(*lplpKeyName)) * sizeof(TCHAR);
lpResult = HeapAlloc(GetProcessHeap(), 0, len);
if (!lpResult) /* that would be very odd */
return NULL;
memcpy(lpResult, *lplpKeyName, len-1);
lpResult[len-1] = '\0';
*lplpKeyName = *lpPos ? lpPos+1 : NULL;
return lpResult;
}
#define CHECK_PAIR(name) \
if (!_tcsicmp(lpKeyName, _T(#name))) return name;
static HKEY get_predefined_key(LPCTSTR lpKeyName) {
CHECK_PAIR(HKEY_CLASSES_ROOT)
CHECK_PAIR(HKEY_CURRENT_USER)
CHECK_PAIR(HKEY_LOCAL_MACHINE)
CHECK_PAIR(HKEY_USERS)
CHECK_PAIR(HKEY_DYN_DATA)
CHECK_PAIR(HKEY_PERFORMANCE_DATA)
return NULL;
}
HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName) {
TVITEMEX tvi;
TCHAR buf[261]; /* tree view has 260 character limitation on item name */
HTREEITEM hItem, hOldItem;
buf[260] = '\0';
hItem = TreeView_GetRoot(hwndTV);
TreeView_Expand(hwndTV, hItem, TVE_EXPAND);
hItem = TreeView_GetChild(hwndTV, hItem);
hOldItem = hItem;
while(1) {
LPTSTR lpItemName = get_path_component(&lpKeyName);
if (lpItemName) {
while(hItem) {
tvi.mask = TVIF_TEXT | TVIF_HANDLE;
tvi.hItem = hItem;
tvi.pszText = buf;
tvi.cchTextMax = 260;
TreeView_GetItem(hwndTV, &tvi);
if (!_tcsicmp(tvi.pszText, lpItemName)) {
TreeView_Expand(hwndTV, hItem, TVE_EXPAND);
if (!lpKeyName)
return hItem;
hOldItem = hItem;
hItem = TreeView_GetChild(hwndTV, hItem);
break;
}
hItem = TreeView_GetNextSibling(hwndTV, hItem);
}
if (!hItem)
return hOldItem;
HeapFree(GetProcessHeap(), 0, lpItemName);
}
else
return hItem;
}
}
BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
{
if (!hItem) hItem = TreeView_GetSelection(hwndTV);