From 75eae135f9738fecb8e57dec135882f0a97bd715 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Mon, 21 Mar 2005 11:23:40 +0000 Subject: [PATCH] Always display path in status bar. --- programs/regedit/childwnd.c | 49 ++++++++++++++++++++++++------------- programs/regedit/framewnd.c | 12 ++++----- programs/regedit/main.h | 1 + 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c index d7773f29206..8ec6d70056b 100644 --- a/programs/regedit/childwnd.c +++ b/programs/regedit/childwnd.c @@ -83,6 +83,35 @@ 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); + } + } + 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); + } +} + /******************************************************************************* * * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG) @@ -238,23 +267,9 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa switch (((LPNMHDR)lParam)->code) { case TVN_ITEMEXPANDING: return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); - case TVN_SELCHANGED: { - LPCTSTR keyPath, rootName; - LPTSTR fullPath; - HKEY hRootKey; - - keyPath = GetItemPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey); - if (keyPath) { - RefreshListView(pChildWnd->hListWnd, 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); - } - } - } + case TVN_SELCHANGED: + OnTreeSelectionChanged(pChildWnd->hTreeWnd, pChildWnd->hListWnd, + ((NMTREEVIEW *)lParam)->itemNew.hItem, TRUE); break; case NM_SETFOCUS: pChildWnd->nFocusPanel = 0; diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 7818f63b26a..65d33f17f45 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -121,16 +121,16 @@ void SetupStatusBar(HWND hWnd, BOOL bResize) if (bResize) SendMessage(hStatusBar, WM_SIZE, 0, 0); SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); + UpdateStatusBar(); } void UpdateStatusBar(void) { - TCHAR text[260]; - DWORD size; - - size = sizeof(text)/sizeof(TCHAR); - GetComputerName(text, &size); - SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text); + /* 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); } static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) diff --git a/programs/regedit/main.h b/programs/regedit/main.h index 9a6dd4e307c..fc6837310c8 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -103,6 +103,7 @@ 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);