Commit 83edf205 authored by Krzysztof Foltman's avatar Krzysztof Foltman Committed by Alexandre Julliard

- Copy key name works.

- Favorites (adding, removing, going to) work. - Added context sensitive graying to some menu options. - Cleanup of status bar update.
parent baab789c
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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;
}
}
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 {
/* else the computer icon is being selected, so display computer name */
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];
DWORD size;
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);
}
size = sizeof(text)/sizeof(TCHAR);
GetComputerName(text, &size);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text);
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();
}
/*******************************************************************************
......
......@@ -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);
......
......@@ -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
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment