Managing the Windows 7 Explorer Navigation Bar

Based on the responses I received from the superuser , it became clear that I would have to add the following to the Explorer custom launchpad. I want to launch a viewport with root and for this window make the navigation bar look like the panel of old Windows XP folders. I already wrote a program for placing shortcuts for these folder views in the Start menu, so changing the shortcuts for launching through the launchpad is trivial.

Here is the XP folder bar:

Windows XP Explorer Folders Pane

Here is the Windows 7 navigation bar:

Windows 7 Explorer Navigation Pane
(source: 280z28.org )

+5
navigation windows-explorer windows-shell
source share
3 answers

Well, I donโ€™t have time to finish this code completely (and it is in C #, which I have no idea what you want, but you did not specify). The main premise of this is to place the ExplorerBrowser control inside a .NET form (using the WindowsAPICodePack , which you will need to get and add a link to), wait until the TreeView is created and the window is subclassed so that we can intercept the element inserts.

Unfortunately, nothing is ever simple, the text does not give you a direct idea that the element (because it does not define it), what you need to do is get the PIDL from insertStruct.lParam and analyze it into something meaningful, possibly using the IShellFolder interface. Then you can selectively delete elements (returning 0 as m.Result ), and you can intercept everything you need. You might think that there would be a simple solution, but I think you're out of luck;) I hope this helps a bit.

An alternative could be a similar one (host explorer directly), but use something like detours to enable registry functions and selectively change the browser control view to allow some registry settings.

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.WindowsAPICodePack.Shell; using System.Runtime.InteropServices; namespace MyExplorer { public partial class Form1 : Form { const int WH_CALLWNDPROC = 4; const int WM_CREATE = 1; public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId); [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern bool UnhookWindowsHookEx(IntPtr hHook); [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern int CallNextHookEx(IntPtr hHook, int nCode, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); IntPtr m_hHook; HookProc HookDelegate; struct WindowHookStruct { public IntPtr lParam; public IntPtr wParam; public uint message; public IntPtr hwnd; } public class SubclassTreeView : NativeWindow { const int TV_FIRST = 0x1100; //const int TVM_INSERTITEMA = (TV_FIRST + 0); const int TVM_INSERTITEMW = (TV_FIRST + 50); struct TVINSERTSTRUCTW { public IntPtr hParent; public IntPtr hInsertAfter; /* TVITEMW */ public uint mask; public IntPtr hItem; public uint state; public uint stateMask; public IntPtr pszText; public int cchTextMax; public int iImage; public int iSelectedImage; public int cChildren; public IntPtr lParam; } int count = 0; protected override void WndProc(ref Message m) { bool bHandled = false; switch (m.Msg) { case TVM_INSERTITEMW: TVINSERTSTRUCTW insertStruct = (TVINSERTSTRUCTW)Marshal.PtrToStructure(m.LParam, typeof(TVINSERTSTRUCTW)); /* Change text to prove a point */ string name = String.Format("{0:X} {1} Hello", insertStruct.hParent.ToInt64(), count++); insertStruct.pszText = Marshal.StringToBSTR(name); insertStruct.cchTextMax = name.Length+1; Marshal.StructureToPtr(insertStruct, m.LParam, false); /* insertStruct.lParam is a pointer to a IDL, use IShellFolder::GetDisplayNameOf to pull out a sensible name to work out what to hide */ /* Uncomment this code to delete the entry */ //bHandled = true; //m.Result = IntPtr.Zero; break; } if (!bHandled) { base.WndProc(ref m); } } } /* Not complete structure, don't need it */ struct MSG { public IntPtr hwnd; public uint message; public IntPtr wParam; public IntPtr lParam; } SubclassTreeView sc = null; public Form1() { InitializeComponent(); HookDelegate = new HookProc(HookWindowProc); m_hHook = SetWindowsHookEx(WH_CALLWNDPROC, HookDelegate, (IntPtr)0, AppDomain.GetCurrentThreadId()); } int HookWindowProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0) { return CallNextHookEx(m_hHook, nCode, wParam, lParam); } else { WindowHookStruct hookInfo = (WindowHookStruct)Marshal.PtrToStructure(lParam, typeof(WindowHookStruct)); StringBuilder sb = new StringBuilder(1024); if (hookInfo.message == WM_CREATE) { if (GetClassName(hookInfo.hwnd, sb, 1024) > 0) { System.Diagnostics.Debug.WriteLine(sb.ToString()); if (sb.ToString() == "SysTreeView32") { sc = new SubclassTreeView(); sc.AssignHandle(hookInfo.hwnd); UnhookWindowsHookEx(m_hHook); } } } return CallNextHookEx(m_hHook, nCode, wParam, lParam); } } private void Form1_Load(object sender, EventArgs e) { explorerBrowser1.Navigate(ShellLink.FromParsingName("C:\\")); } } } 
+3
source share

If you can get a pointer to the Explorer instance interface IShellFolderViewDual2 or IShellFolderViewDual3 , then the ViewOptions method allows ViewOptions to specify SFVVO_WIN95CLASSIC .

0
source share

In Win 7, it is impossible to accomplish what you ask, that is, adjust the appearance of the Explorer window to remove all elements (libraries, preferences, etc.) from the navigation bar, with the exception of the folder tree, for one instance of Explorer. You can do this, as you may have discovered, as a system-wide setting, by modifying the registry in 4 places. Alternatively and simply, you can set "Show all folders" on the navigation bar in the properties window of the explorer (if you don't care that the "Favorites" link still exists). However, both are system-wide settings and will affect all browser windows.

Sorry, I know that this does not give you what you need, but system-wide settings are your only options for removing these items from the navigation bar. (By the way, you are not alone here - there are many people who prefer the XP Explorer view).

-one
source share

All Articles