Regedit enhancements
1. Implemented the ability to select existing favorites
2. Created dialog resources for adding favorites, removing favorites,
and the find dialog
Modified: trunk/reactos/subsys/system/regedit/En.rc
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
Modified: trunk/reactos/subsys/system/regedit/main.c
Modified: trunk/reactos/subsys/system/regedit/resource.h
Modified: trunk/reactos/subsys/system/regedit/treeview.c
_____
Modified: trunk/reactos/subsys/system/regedit/En.rc
--- trunk/reactos/subsys/system/regedit/En.rc 2005-11-22 22:19:18 UTC
(rev 19471)
+++ trunk/reactos/subsys/system/regedit/En.rc 2005-11-23 00:09:17 UTC
(rev 19472)
@@ -370,16 +370,51 @@
EDITTEXT IDC_EXPORT_BRANCH_TEXT,30,34,335,12
END
-IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95
+IDD_ADDFAVORITES DIALOG DISCARDABLE 0, 0, 186, 46
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
+CAPTION "Add to Favorites"
FONT 8, "MS Sans Serif"
BEGIN
- DEFPUSHBUTTON "OK",IDOK,130,7,50,14
- PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14
+ DEFPUSHBUTTON "OK",IDOK,129,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
+ LTEXT "&Favorite Name:",IDC_STATIC,7,7,70,10
+ EDITTEXT IDC_FAVORITENAME,7,26,110,13,ES_AUTOHSCROLL
END
+IDD_REMOVEFAVORITES DIALOG DISCARDABLE 0, 0, 164, 135
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Remove Favorites"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,107,114,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,7,114,50,14
+ CONTROL
"List1",IDC_FAVORITESLIST,"SysListView32",LVS_LIST
|
+ WS_BORDER | WS_TABSTOP,7,20,150,90
+ LTEXT "Select Favorite(s):",IDC_STATIC,7,7,99,12
+END
+IDD_FIND DIALOG DISCARDABLE 0, 0, 254, 82
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Find"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "&Find Next",IDOK,197,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,197,24,50,14
+ GROUPBOX "Look at",IDC_STATIC,7,25,63,51
+ LTEXT "Fi&nd what:",IDC_STATIC,7,8,37,10
+ EDITTEXT IDD_FINDWHAT,47,7,142,13,ES_AUTOHSCROLL
+ CONTROL
"&Keys",IDC_LOOKAT_KEYS,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,14,36,35,8
+ CONTROL
"&Values",IDC_LOOKAT_VALUES,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,14,48,36,8
+ CONTROL
"&Data",IDC_LOOKAT_DATA,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,14,60,42,8
+ CONTROL "Match &whole string
only",IDC_MATCHSTRING,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,83,32,94,13
+ CONTROL "Match
&case",IDC_MATCHCASE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,83,48,90,12
+END
+
/*
* TEXTINCLUDE
*/
_____
Modified: trunk/reactos/subsys/system/regedit/framewnd.c
--- trunk/reactos/subsys/system/regedit/framewnd.c 2005-11-22
22:19:18 UTC (rev 19471)
+++ trunk/reactos/subsys/system/regedit/framewnd.c 2005-11-23
00:09:17 UTC (rev 19472)
@@ -37,6 +37,10 @@
* Global and Local Variables:
*/
+#define FAVORITES_MENU_POSITION 3
+
+static TCHAR s_szFavoritesRegKey[] =
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favo
rites");
+
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the
menu loop */
/***********************************************************************
********
@@ -79,13 +83,12 @@
DWORD dwIndex, cbValueName, cbValueData, dwType;
TCHAR szValueName[256];
BYTE abValueData[256];
- int nFavoriteMenuPos = 3;
static int s_nFavoriteMenuSubPos = -1;
HMENU hMenu;
BOOL bDisplayedAny = FALSE;
/* Find Favorites menu and clear it out */
- hMenu = GetSubMenu(GetMenu(hWnd), nFavoriteMenuPos);
+ hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION);
if (!hMenu)
goto done;
if (s_nFavoriteMenuSubPos < 0)
@@ -98,7 +101,7 @@
;
}
- lResult = RegOpenKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favo
rites"), &hKey);
+ lResult = RegOpenKey(HKEY_CURRENT_USER, s_szFavoritesRegKey,
&hKey);
if (lResult != ERROR_SUCCESS)
goto done;
@@ -115,7 +118,7 @@
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
bDisplayedAny = TRUE;
}
- AppendMenu(hMenu, MF_GRAYED, 0, szValueName);
+ AppendMenu(hMenu, 0, ID_FAVORITES_MIN +
GetMenuItemCount(hMenu), szValueName);
}
dwIndex++;
}
@@ -524,6 +527,28 @@
return TRUE;
}
+static void ChooseFavorite(LPCTSTR pszFavorite)
+{
+ HKEY hKey = NULL;
+ TCHAR szFavoritePath[512];
+ DWORD cbData, dwType;
+
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, s_szFavoritesRegKey, 0,
KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+ goto done;
+
+ cbData = (sizeof(szFavoritePath) / sizeof(szFavoritePath[0])) - 1;
+ memset(szFavoritePath, 0, sizeof(szFavoritePath));
+ if (RegQueryValueEx(hKey, pszFavorite, NULL, &dwType, (LPBYTE)
szFavoritePath, &cbData) != ERROR_SUCCESS)
+ goto done;
+
+ if (dwType == REG_SZ)
+ SelectNode(g_pChildWnd->hTreeWnd, szFavoritePath);
+
+done:
+ if (hKey)
+ RegCloseKey(hKey);
+}
+
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCTSTR keyName)
{
BOOL bClipboardOpened = FALSE;
@@ -962,7 +987,31 @@
CreateNewKey(g_pChildWnd->hTreeWnd,
TreeView_GetSelection(g_pChildWnd->hTreeWnd));
break;
default:
- result = FALSE;
+ if ((LOWORD(wParam) >= ID_FAVORITES_MIN) && (LOWORD(wParam) <=
ID_FAVORITES_MAX))
+ {
+ HMENU hMenu;
+ MENUITEMINFO mii;
+ TCHAR szFavorite[512];
+
+ hMenu = GetSubMenu(GetMenu(hWnd), FAVORITES_MENU_POSITION);
+
+ memset(&mii, 0, sizeof(mii));
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_TYPE;
+ mii.fType = MFT_STRING;
+ mii.dwTypeData = szFavorite;
+ mii.cch = sizeof(szFavorite) / sizeof(szFavorite[0]);
+
+ if (GetMenuItemInfo(hMenu, LOWORD(wParam) -
ID_FAVORITES_MIN, TRUE, &mii))
+ {
+ ChooseFavorite(szFavorite);
+ }
+ }
+ else
+ {
+ result = FALSE;
+ }
+ break;
}
if(hKey)
_____
Modified: trunk/reactos/subsys/system/regedit/main.c
--- trunk/reactos/subsys/system/regedit/main.c 2005-11-22 22:19:18 UTC
(rev 19471)
+++ trunk/reactos/subsys/system/regedit/main.c 2005-11-23 00:09:17 UTC
(rev 19472)
@@ -76,7 +76,6 @@
BOOL AclUiAvailable;
HMENU hEditMenu;
TCHAR szBuffer[256];
- LPCTSTR s;
WNDCLASSEX wcFrame = {
sizeof(WNDCLASSEX),
@@ -168,10 +167,7 @@
_T("LastKey"),
szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0])) ==
ERROR_SUCCESS)
{
- s = szBuffer;
- if (!_tcsncmp(s, _T("My Computer\\"), 12))
- s += 12;
- SelectNode(g_pChildWnd->hTreeWnd, s);
+ SelectNode(g_pChildWnd->hTreeWnd, szBuffer);
}
ShowWindow(hFrameWnd, nCmdShow);
_____
Modified: trunk/reactos/subsys/system/regedit/resource.h
--- trunk/reactos/subsys/system/regedit/resource.h 2005-11-22
22:19:18 UTC (rev 19471)
+++ trunk/reactos/subsys/system/regedit/resource.h 2005-11-23
00:09:17 UTC (rev 19472)
@@ -37,12 +37,14 @@
#define IDR_REGEDIT_MENU 130
#define IDD_EXPORTRANGE 131
#define IDI_OPEN_FILE 132
-#define IDD_DIALOG2 132
#define IDI_CLOSED_FILE 133
#define IDI_ROOT 134
#define IDI_STRING 135
#define IDI_BIN 136
#define IDR_POPUP_MENUS 137
+#define IDD_ADDFAVORITES 138
+#define IDD_REMOVEFAVORITES 139
+#define IDD_FIND 140
#define IDC_LICENSE_EDIT 1029
#define ID_REGISTRY_EXIT 32770
#define ID_FAVOURITES_ADDTOFAVOURITES 32772
@@ -188,4 +190,17 @@
#define IDC_EXPORT_BRANCH 2009
#define IDC_EXPORT_BRANCH_TEXT 2010
+
+#define IDC_FAVORITENAME 2011
+#define IDC_FAVORITESLIST 2012
+#define IDD_FINDWHAT 2013
+#define IDC_LOOKAT_KEYS 2014
+#define IDC_LOOKAT_VALUES 2015
+#define IDC_LOOKAT_DATA 2016
+#define IDC_MATCHSTRING 2017
+#define IDC_MATCHCASE 2018
+
+#define ID_FAVORITES_MIN 2100
+#define ID_FAVORITES_MAX 2999
+
#define IDC_STATIC -1
_____
Modified: trunk/reactos/subsys/system/regedit/treeview.c
--- trunk/reactos/subsys/system/regedit/treeview.c 2005-11-22
22:19:18 UTC (rev 19471)
+++ trunk/reactos/subsys/system/regedit/treeview.c 2005-11-23
00:09:17 UTC (rev 19472)
@@ -598,6 +598,10 @@
LPCTSTR s;
TVITEM tvi;
+ /* Total no-good hack */
+ if (!_tcsncmp(keyPath, _T("My Computer\\"), 12))
+ keyPath += 12;
+
hRoot = TreeView_GetRoot(hwndTV);
hItem = hRoot;