Always display path in status bar.

This commit is contained in:
Robert Shearman 2005-03-21 11:23:40 +00:00 committed by Alexandre Julliard
parent 77da3d2d39
commit 75eae135f9
3 changed files with 39 additions and 23 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);