答案1
我无法保证 TextPad 的最新版本,因为我还没有尝试过。不过 Textpad v5.4.2 有一个永久文件夹/文件树。查看 > 资源管理器。
Notepad++ 有一个名为 Light Explorer 的插件,可以对文件进行树形视图。安装方法:
- 下载 Notepad++
- 插件 > 插件管理器 > 显示插件管理器 > 可用 > Light Explorer
- 此后,它将在顶部工具栏中添加一个文件夹快捷方式
您还可以在其自己的实例与另一个 notepad++ 安装分开。它将在任务栏中占用一个单独的空间,这很好。见下文:
- 下载 notepad++ v5.7: https://notepad-plus-plus.org/download/v5.7.html(.zip 文件)
- 下载 LightExplorer.dll (UNICODE) {我使用的是 v2.0Unicode}: https://sourceforge.net/projects/npp-plugins/files/LightExplorer/
- 复制/粘贴到插件目录。
- 打开 notepad++ 插件 > Light Explorer > Light Explorer
- 全屏光之探索者
- 从 notepad++.exe 创建快捷方式
- 将快捷方式的图标更改为文件夹图标以便在任务栏中以不同方式显示. 文件夹图标位于:C:\Windows\System32\shell32.dll
以下是 Yashied 的 Autoit 片段: https://www.autoitscript.com/forum/topic/124430-display-on-the-fly-a-directory-tree-in-a-treeview/
#Include <GUIConstantsEx.au3>
#Include <GUIImageList.au3>
#Include <GUITreeView.au3>
#Include <TreeViewConstants.au3>
#Include <WindowsConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $hTreeView, $hImageList, $hItem, $hNext, $hSelect = 0, $hInput, $Input, $Dummy1, $Dummy2
Global $X, $Y, $sPath, $sRoot = @HomeDrive
$hForm = GUICreate('MyGUI', 600, 600)
$Input = GUICtrlCreateInput('', 20, 20, 560, 19)
$hInput = GUICtrlGetHandle(-1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateTreeView(20, 50, 560, 530, -1, $WS_EX_CLIENTEDGE)
$hTreeView = GUICtrlGetHandle(-1)
$Dummy1 = GUICtrlCreateDummy()
$Dummy2 = GUICtrlCreateDummy()
If _WinAPI_GetVersion() >= '6.0' Then
_WinAPI_SetWindowTheme($hTreeView, 'Explorer')
EndIf
$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 3)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 4)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
$sRoot = StringRegExpReplace($sRoot, '\\+\Z', '')
$sPath = StringRegExpReplace($sRoot, '^.*\\', '')
If StringInStr($sPath, ':') Then
$sRoot &= '\'
$sPath &= '\'
EndIf
;_GUICtrlTreeView_BeginUpdate($hTreeView)
_TVUpdate($hTreeView, _GUICtrlTreeView_AddChild($hTreeView, 0, $sPath, 0, 0))
;_GUICtrlTreeView_EndUpdate($hTreeView)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
_GUICtrlTreeView_Expand($hTreeView, _GUICtrlTreeView_GetFirstItem($hTreeView))
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Dummy1 ; Update
GUISetCursor(1, 1)
$hItem = _GUICtrlTreeView_GetFirstChild($hTreeView, GUICtrlRead($Dummy1))
If $hItem Then
While $hItem
$hNext = _GUICtrlTreeView_GetNextSibling($hTreeView, $hItem)
If Not _TVUpdate($hTreeView, $hItem) Then
_GUICtrlTreeView_Delete($hTreeView, $hItem)
EndIf
$hItem = $hNext
WEnd
_WinAPI_RedrawWindow($hTreeView)
EndIf
GUISetCursor(2, 0)
Case $Dummy2 ; Menu
$hItem = GUICtrlRead($Dummy2)
$sPath = _TVGetPath($hTreeView, $hItem, $sRoot)
ConsoleWrite('-------------------------------' & @CR)
ConsoleWrite('Handle: ' & $hItem & @CR)
ConsoleWrite('Path: ' & $sPath & @CR)
If _WinAPI_PathIsDirectory($sPath) Then
ConsoleWrite('Type: ' & 'Directory' & @CR)
Else
ConsoleWrite('Type: ' & 'File' & @CR)
EndIf
ConsoleWrite('X: ' & MouseGetPos(0) & @CR)
ConsoleWrite('Y: ' & MouseGetPos(1) & @CR)
ConsoleWrite('-------------------------------' & @CR)
EndSwitch
WEnd
Func _TVGetPath($hTV, $hItem, $sRoot)
Local $Path = StringRegExpReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), '([|]+)|(\\[|])', '\\')
If Not $Path Then
Return ''
EndIf
If Not StringInStr($Path, ':') Then
Return StringRegExpReplace($sRoot, '(\\[^\\]*(\\|)+)\Z', '\\') & $Path
EndIf
Return $Path
EndFunc ;==>_TVGetPath
Func _TVSetPath($hTV, $hItem, $sRoot)
GUICtrlSetData($Input, _WinAPI_PathCompactPath($hInput, _TVGetPath($hTV, $hItem, $sRoot), 554))
$hSelect = $hItem
EndFunc ;==>_TVSetPath
Func _TVUpdate($hTV, $hItem)
Local $hImageList = _SendMessage($hTV, $TVM_GETIMAGELIST)
Local $Path = StringRegExpReplace(_TVGetPath($hTV, $hItem, $sRoot), '\\+\Z', '')
Local $hSearch, $hIcon, $Index, $File
$hSearch = FileFindFirstFile($Path & '\*')
If $hSearch = -1 Then
If Not @error Then
If FileExists($Path) Then
; If _WinAPI_PathIsDirectory($Path) Then
; ; Access denied
; EndIf
Else
Return 0
EndIf
EndIf
Else
While 1
$File = FileFindNextFile($hSearch)
If @error Then
ExitLoop
EndIf
If @extended Then
_GUICtrlTreeView_AddChild($hTV, $hItem, $File, 0, 0)
EndIf
WEnd
FileClose($hSearch)
EndIf
$hSearch = FileFindFirstFile($Path & '\*')
If $hSearch = -1 Then
Else
While 1
$File = FileFindNextFile($hSearch)
If @error Then
ExitLoop
EndIf
If Not @extended Then
$hIcon = _WinAPI_ShellExtractAssociatedIcon($Path & '\' & $File, 1)
$Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
_GUICtrlTreeView_AddChild($hTV, $hItem, $File, $Index, $Index)
_WinAPI_DestroyIcon($hIcon)
EndIf
WEnd
FileClose($hSearch)
EndIf
Return 1
EndFunc ;==>_TVUpdate
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam)
Local $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
Local $iState = DllStructGetData($tNMTREEVIEW, 'NewState')
Local $hTV = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
Local $ID = DllStructGetData($tNMTREEVIEW, 'Code')
Local $tTVHTI, $tPoint
Switch $hTV
Case $hTreeView
Switch $ID
Case $TVN_ITEMEXPANDEDW
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
If BitAND($iState, $TVIS_SELECTED) Then
_TVSetPath($hTV, _GUICtrlTreeView_GetSelection($hTV), $sRoot)
EndIf
Else
If Not BitAND($iState, $TVIS_EXPANDED) Then
_GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 0)
_GUICtrlTreeView_SetImageIndex($hTV, $hItem, 0)
Else
_GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 1)
_GUICtrlTreeView_SetImageIndex($hTV, $hItem, 1)
If Not _GUICtrlTreeView_GetItemParam($hTV, $hItem) Then
_GUICtrlTreeView_SetItemParam($hTV, $hItem, 0x7FFFFFFF)
GUICtrlSendToDummy($Dummy1, $hItem)
EndIf
EndIf
EndIf
Case $TVN_SELCHANGEDW
If BitAND($iState, $TVIS_SELECTED) Then
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
$hItem = _GUICtrlTreeView_GetSelection($hTV)
EndIf
If $hItem <> $hSelect Then
_TVSetPath($hTV, $hItem, $sRoot)
EndIf
EndIf
Case $NM_RCLICK
$tPoint = _WinAPI_GetMousePos(1, $hTV)
$tTVHTI = _GUICtrlTreeView_HitTestEx($hTV, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2))
$hItem = DllStructGetData($tTVHTI, 'Item')
If BitAND(DllStructGetData($tTVHTI, 'Flags'), $TVHT_ONITEM) Then
_GUICtrlTreeView_SelectItem($hTreeView, $hItem)
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
$hItem = _GUICtrlTreeView_GetSelection($hTV)
Else
GUICtrlSendToDummy($Dummy2, $hItem)
EndIf
If $hItem <> $hSelect Then
_TVSetPath($hTV, $hItem, $sRoot)
EndIf
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
上面的代码片段为每个文件提供了正确的图标。它不如下面的代码片段快。没有拖放功能。但肯定可以添加。
这是来自 spudw2k 的另一个 Autoit 片段:https://www.autoitscript.com/forum/topic/80327-filebrowser-with-treeview/?do=findComment&comment=580714
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiTreeView.au3>
#Include <File.au3>
$gui = GUICreate("File Browser", 362, 378, -1, -1)
$tree = GUICtrlCreateTreeView(0, 0, 361, 377)
GUICtrlSetFont(-1,10)
GUICtrlSetColor($tree, 0x00FF00)
GUICtrlSetBkColor($tree,0x000000)
$hImage = _GUIImageList_Create(16, 16, 5, 2)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 4)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 54)
_GUICtrlTreeView_SetNormalImageList($tree, $hImage)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$root = _GUICtrlTreeView_AddChild($tree,"","C:",0)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
If $msg= -3 Then ExitLoop
WEnd
Func _SearchFolder($folder,$parent,$level=0)
If $level >= 1 Then Return
$files = _FileListToArray($folder,"*",1)
$folders = _FileListToArray($folder,"*",2)
_FolderFunc($folders,$folder,$parent,$level)
_FileFunc($files,$parent)
EndFunc
Func _FileFunc($files,$parent)
For $i = 1 To UBound($files)-1
_GUICtrlTreeView_AddChild($tree,$parent,$files[$i],1,1)
Next
EndFunc
Func _FolderFunc($folders,$folder,$parent,$level)
For $i = 1 To UBound($folders)-1
$parentitem = _GUICtrlTreeView_AddChild($tree,$parent,$folders[$i],0)
_SearchFolder($folder & "\" & $folders[$i],$parentitem,$level+1)
Next
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$hWndTreeView = GUICtrlGetHandle($tree)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeView
Switch $iCode
Case -451
$item = _GUICtrlTreeView_GetSelection($hWndTreeView)
$root = $item
If _GUICtrlTreeView_GetChildCount($hWndTreeView,$item) <= 0 Then
$txt = _GUICtrlTreeView_GetText($hWndTreeView,$item)
Do
$parent = _GUICtrlTreeView_GetParentHandle($hWndTreeView,$item)
If $parent <> 0 Then
$txt = _GUICtrlTreeView_GetText($hWndTreeView,$parent) & "\" & $txt
$item = $parent
EndIf
Until $parent = 0
_SearchFolder($txt,$root)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
上面的代码片段没有每个文件的正确图标,但速度却出奇地快。无需拖放。
这是.NET 源代码这正是您所要求的。您所要做的就是进行修改以满足您的需求:
https://code.msdn.microsoft.com/windowsapps/File-System-Tree-View-3a28325c
对于那些没有能力修改源代码的人,我已经获取了上述源代码,做了一些修改,并编译了可执行文件。 这里是:
https://www.dropbox.com/s/xb4f3skrcs20om4/ExplorerTreee.zip?dl=1
另外,还有一个名为选项卡栏可以通过上下文菜单的形式执行此操作:
但是这个程序有两个版本。1038 的安装包比较遗憾,但是功能丰富而且很棒。1.5.0.0 Beta 2 的安装包很棒,但是不那么棒,功能也不那么多。
你也许可以做一个插入为了超赞版本 1038它将具有一个包含文件的持久树视图。
你可以修改 Good 安装程序版本 1.5.0.0 Beta 2 的源代码获取包含文件的持久树视图。
有时,Awesome 版本可以很好地安装在某些 PC 上。我以前安装 Awesome 版本时遇到过问题,我解决这个问题的方法是安装带有 Awesome 安装程序的版本。