The VB6 version here is out of date and several versions behind the twinBASIC version.
It's recommended that you use that version; you can compile to an ocx for use in VB6. ucShellBrowse v12.2 (32bit/64bit)
About
ucShellBrowse is a highly customizable UserControl meant to view the file system. It can be configured, very easily with the standard properties window, as simple as the old VB DirList/FileListBox, or up to all the major features of a full Explorer window, and everything in between.
This is basically having an updated, prettier version of VB's DirList/FileListBox, with further options that allow it to have the power of an actual Explorer window-- but doing it with a ComboBoxEx and ListView allow for customizations and features not possible if you were to simply host an instance of Explorer itself instead. It integrates many of the techniques my small sample projects have shown over the past few years.
Probably the most interesting thing you'll find is the deep dive into the Property System that was involved in recreating Explorer's Details Pane. There's the official documentation of course, but I've never seen any actual code in any language, let alone VB, that takes things all the way down to figuring out which properties should be in the detail bar set, what type of properties they are, listing ranges or combolists full of specialized items like the dozens of different 'Flash Mode' options on a photo, and actually editing and writing it all back on top of reading.
Key Features
Explorer-style Details Pane that shows all the same fully formatted properties. Editing properties is supported, including pop-up DateTime and ComboBox controls where needed.
Supports both dragging out and receiving dropped files, complete with the file icons you see in Explorer. Drops go through Explorer, meaning 3rd party shell extensions like WinRAR are supported.
Dynamic Drag-Drop: Drop on a folder or zip file within the current directory.
Keeps up with changes to the current directory by watching SHChangeNotify
Full Unicode support
Icons, display names, and properties are identical to what a user sees in Explorer. Includes overlay icons for things like shares or links; supports custom ones like used by DropBox or Github.
Full navigation tree from the desktop-- virtual objects that are part of the file system, such as Computer or Libraries, are able to be used normally, and the selections real file system path is resolved and returned.
In addition to the above, attached devices like phones, cameras, etc, can be navigated and used just like Explorer.
Support for several different view modes: XL Icon, Large icon, Medium Icon, Small Icon, List, Details, Tiles, Contents, and Thumbnails.
All column headers found in Explorer are available to be added/removed/sorted by/grouped by, directly interfacing with the Windows Property System and each files Property Store.
Default column headers are loaded for each folder from Explorer; so when you browse to your Music library you get Artist, Album, Title, and Track as the columns (this behavior can be disabled)
Thumbnail View uses the code from my ThumbsEx project, which goes beyond what Explorer can do by using GDI+ to center and frame images smaller than the thumbnail size. The thumbnail size can be set to any value.
Optional setting to enable extended thumbnails, like video files showing the first frame.
Images and all types with a registered preview handler can be previewed in an optional preview pane.
'Group by' is fully implemented; can group for extended properties
Right click brings up the standard shell context menu
Sort is supported for all columns and uses the same API that is used by Explorer, so order is identical
A filter can be applied to only show files matching a certain type (PathMatchSpecW); an option specifies whether it's single-select or multi-select.
Supports rename-in-place with ListView LabelEdit, with blocks and warning popups to prevent disallowed characters. Renames are carried out through Explorer via IFileOperation.
Rename, and other functionality, is still supported even if file name extensions are hidden (the ListView uses the Explorer displayname, so if they're hidden in Explorer they're hidden here)
Supports 'Create new folder' where a new folder is created, with its name the next in sequence if needed, and a label edit to rename is automatically initiated.
Optional status bar that shows the number of files, their total size, and menu item help. A custom message can also be set.
The Back/Up/View control box can be shown or hidden; this combined with option to limit or turn off columns allows for compacting down to the same size as the original VB file browsing controls. ListView icons can even be hidden.
There's substantial interaction with the host form, informing your program of selection change, clicks, double clicks/enter press, directory change, renames, and file drops. These events provide both full paths and references to the file(s) IShellItem(Array) interfaces
The startup path can be customized and is remembered. Options to start in the last path, or a completely blank display in no folder. The current path can be manually changed through a .BrowserPath property.
Custom draw is used to show encrypted files in green and compressed files in blue to be consistent with Explorer (this can also be forced on or forced off)
A footer bar can be added to the file list (like in Explorer search results).
Explorer-style tool tips show details about the selected item; the properties shown depend on the file type, loading the same ones as Explorer does.
Search box, with additional options in pop-up, launches a search of the current location and displays the results as a folder.
Opens certain internet locations that Explorer can open. For example, you can set an ftp:// URL as the BrowserPath or Dropdown root, and the ftp site will successfully load.
NEW: Highly portable - There's no BAS files, property pages, or additional classes. You need only add the .ctl and (recommended) manifest enabling Common Controls 6 if not already present, and just for the IDE, a single TLB reference.
There's also fairly extensive debug output to the Immediate window. You can stop it from appearing by changing the option: Private Const dbg_PrintToImmediate As Boolean = True --Change it to False to stop debug printing. This and other code options immediately follows the changelog in ucShellBrowse.ctl.
Requirements
-Windows Vista or newer
-If using this as a .ctl, your project must have a reference to oleexp.tlb v4.61 or higher (released 03 Oct 2019).
(Tested on Windows 7 Ent, Windows 8 Pro, and Windows 10 1709/Fall Creators)
Strongly recommended:
-Common Controls 6.0 manifest (for a tool to make them, see LaVolpe's Manifest Creator). The control does work without this, but some features are missing/degraded. Button icons in the control box won't show up. The View mode (Details, Large Icons, List, etc) can't be changed at runtime. Group mode, tile view, thumbnail view, and footer items are all unavailable. When renaming, the extension can't be excluded by default.
The resource file in the download and used by the demo projects contains a manifest. It also turns on DPI awareness, since this control does its own high DPI support. There's an alternative file for the Demo project without DPIAware turned on, now included in the Zip instead of separate.
Current Version: 11.2. Recent updates:
Project Update: 11.2
-I haven't had a ton of time to work on this between work and so many other projects, but I did want to release the few small feature updates and bug fixes that have been pending.
Project Update: 11.1
-Wanted to fix a few moderate severity bugs before a major refactor to address some issues. A couple minor features added as well.
Project Update: Version 11.0
-Added a few minor features, including enabling the ability to start a selection marquee in the whitespace of a column like in Explorer, and fixed a number of bugs identified by running it more on Windows 10; Microsoft unexpectedly changed the way a few older APIs worked, among other issues.
Project Update: Version 10.0 Revision 3/4
Revision 4: The fix introduced to stop crashing with a Thicker border was incorrectly applied to the ListView as well, and this caused graphical glitches when resizing the control too short as the ListView locked and the Details Pane and/or StatusBar were drawn on top of it.
Revision 3: The minimum control height for FilesOnly/Dir+Files was applied at runtime for other modes, creating a big empty space below the control, potentially on top of other objects on your form.
I swear I could bug test for a month straight 24/7, then still find something I missed a day later
Project Update: Version 10.0 Revision 2
Had one bug still manage to sneak by
If your startup mode is FilesOnly, but SearchBox was True, if you then switched to a mode that shows the Directory bar during runtime, the SearchBox would not show up, even if you toggled it off and on.
Added the new demo from the 10.0 release post to the zip.
Project Update: Version 10.0
This version update has been adapted and finalized from 9.6 R3/9.7 with several more features/fixes.
Every time I went to save 9.6R3/9.7, a new bug popped up. After it happened a bunch of times, I pulled the entire project entirely. Then, I conducted a thorough review of every single Property and Public method in the control, fixing numerous additional bugs in the process.
With that and a few more features, it's time for a Major Version bump. 10.0 is the most tested version of ucShellBrowse ever.
See the log below for a full list of new features and the extensive bug fix list.
------------
Code:
'New in v11.2 (Released 18 Jun 2022)
'
'-Added SearchAutoGroup to automatically group search results. The default is to
' group them by folder, but you can change that via the szAutoGroupSearchCat
' User Option.
'
'-In addition to below specific bug identified, added a more robust system of
' ensuring duplicates are not added by receiving duplicate ShellNotify messages.
'
'-SelectedFiles (Let) and FileSetCheck are no longer case sensitive.
'
'-Now use Unicode-aware width calculations in Details Pane.
'
'-(Bug fix) In Computer/This PC, for some Windows versions removing a USB device
' then plugging it back in could result in duplicate entries.
' Also improved entry remover to better handle these.
'
'-(Bug fix) SelectedFileSet ignored bDeselectOthers flag.
'
'-(Bug fix) The control improperly reported the Windows version due to Microsoft
' breaking most version functions to require a manifest specifying 10
' compatibility or else it deliberately reports Windows 8. This didn't
' impact functionality as the only version-restricted features were
' Vista+ to run at all, and Windows 8+ for some Bookmarks folders.
'
'-(Bug fix) Since version 9.4, pressing enter in the Search Box accidentally
' had the code to use the legacy search enabled. That would be conducted
' first, then the new search would be conducted. This doubled (at least)
' the search time and created a duplicate folder.
'
'-(Demo) The Demo manifest, with the preferred settings, has been updated to
' include compatibility flags, trust info, and newer dpi awareness.
'
'
'New in v11.1 (Released 02 Feb 2022)
'
'-Provided some advanced item data access. zz_ExportSelectedItemFullData and
' zz_ExportItemFullDataByPos export the full internal item data structure.
' How to use these:
' Step 1: Copy type definitions for UCSBFile, UCSBF_ColLink, and ColumnCache
' to the calling form/module.
' Step 2: Declare a UCSBFile variable, and 3 Long's to be passed as arguments
' for the function: One to receive the memory pointer, and array
' bounds for the LinkCols and ExtColData arrays in UCSBFile.
' Step 3: Redim UCSBFile.LinkCols(nLinkCol) and UCSBFile.ExtColData(nExtColData)
' Step 4: CopyMemory to UCSBFile from ByVal pData (only if function returns >0!)
' Step 5: You *must* zero out the structure with ZeroMemory before the procedure
' exits, otherwise it will free the strings and objects, likely causing
' a crash when the control tries to access them again.
' Note: As Step 5 might suggest, you must treat the structure as read-only.
' Attempting to change values could result in instability or crashing.
' This access is not meant for casual use; unless you really know the ins
' and outs of passing structures like this you're better off just adding
' an export for the fields you need.
'
'-Also added InvokeKeyPress to invoke a key press on the ListView by code. Has
' options for Shift/Control/Alt and whether to raise the ListKeyDown event.
'
'-CustomColor event now includes dwState argument that passes the CDIS_* values
' in NMLVCUSTOMDRAW.iStateId.
' ***EVENT PROTOTYPES ON YOUR FORMS MUST BE UPDATED!***
'
'-Set the ListView LabelEdit edit box length limit to MAX_PATH, to avoid an error
' when attempting rename.
'
'-(Bug fix) In high performance mode, showing hidden would also show superhidden
' as the FILE_ATTRIBUTE_SYSTEM attribute wasn't checked.
'
'-(Bug fix) SelectedFile(Let) and SetSelectedFile selected the wrong file.
'
'-(Bug fix) If FileExtensions was set to AlwaysShow, drive names in This PC would
' not be displayed at all, and some virtual items displayed GUIDs.
'
'-(Bug fix) When switching into some view modes without ComCtl6, an "Invalid
' Window Handle" error would be displayed.
'
'
'
'New in v11.0 (Released 25 Jan 2022)
'
'-Added option ExplorerStyleSelection. Makes the ListView work like Explorer; if
' in Details View with Multiselect enabled, you can start a marquee to select
' multiple files by dragging in the whitespace of the Name column, rather than
' need to go off to the side. Enabled by default.
' Note: Does not work in Windows Vista.
' Note: This is an undocumented ListView feature. As such, it may be dropped from
' future versions of Windows. However, it's confirmed to be working in
' Windows 10, and it will simply stay with the old selection style if the
' call fails, it will not break the control.
'
'-Added ClearSelection method to deselect all items.
'
'-Added new public SelectedFileSet sub with more options; allows select/deselect,
' separate option for focus, option to deselect all others, and ensure visible.
' SelectedFile (Let) wasn't changed since optional arguments aren't allowed and
' adding non-optional ones would break people's existing code.
'
'-SelectedFile (Let) is no longer case sensitive, since filenames are not.
'
'-New SetSelectedItemsEx function that provides a far more robust way of selecting
' files. Supports wildcards for selecting many, limiting to files or folders,
' setting a match limit, and more.
'
'
'-(Bug fix) High performance mode was broken on Windows 10.
'
'-(Bug fix) On some special editions of Windows 10, including LTSC, special folders
' are not included, causing the Bookmarks menu to not show due to a bug
' in handling errors generating that submenu.
'
'-(Bug fix) Some FILETIME and RECT types weren't explicitly defined, leading to
' naming conflict errors in certain scenarios.
'
'-(Bug fix) On some versions of Windows 10, Special folders in This PC were grouped
' with the drives.
'
'-(Bug fix) On Windows 10, some Security Zone icons failed to load.
'
'-(Bug fix) Keyboard focus never went to ucTreeView when on a form w/ ucShellBrowse.
'
'-(Bug fix) The arrow keys wouldn't work on the first click of the ListView.
'New in v10.0 R4 (Released 29 Apr 2021)
'
'-Updated GetPropertyDisplayString snd GetPropertyKeyDisplayString to handle arrays
' in the manual fallback handler for properties without an IPropertyDescription.
'
'-(Bug fix) When the StatusBar and/or DetailsPane was enabled, resizing the control
' below a certain point caused the ListView to stop resizing, forcing the
' bar and pane onto it, causing graphical glitches. This was related to
' the fix put in place to stop crashes from resizing a thicker border too
' low; that code fired when it shouldn't.
'New in v10.0 R3 (Released 29 Apr 2021)
'
'-(Bug fix) The minimum height for the control was being enforced, but was not
' appropriate for DirOnly/DriveOnly/DirOnlyCtl, which left a big chunk
' of blank space under the control that might cover up other objects on
' your form.
'
'New in v10.0 R2 (Released 28 Apr 2021)
'
'-(Bug fix) If the Search Box was enabled, but the mode set to FilesOnly, then you
' changed to Dir+Files or other mode with the top bar, the Search Box
' did not become visible along with everything else.
If there's another feature you'd like to see don't hesitate to suggest it
Works with the ShellTree control
If you'd rather use a TreeView to navigate (or even choose files), you might be interested in ucShellTree, my new Shell Tree Control. Like this project, it implements nearly all of the functionality from Explorer and some additional ones.
It works seamlessly with this project-- see the ucShellBrowse DemoEx sample (it also works stand-alone). As shown on the right, there's even an option to signal showing/hiding it from the ShellBrowse Layout menu.
NEW! I'm also now distributing ucShellBrowse and ucShellTree together as a compiled OCX, complete with SxS resources to create registration-free distributions.
twinBASIC UserControl support has come a long way in recent weeks, and there's now a beta release of this control for tB, compatible with both 32bit and 64bit apps. Makes use of my tbShellLib project to replace oleexp.tlb.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Known Issues
The following are bugs known to exist in the current version. They will be fixed in the next update if possible, but I include fixes here in case it's something you can't wait for.
On certain versions of Windows 11, a crash occurs in FindFirstFileNt on the RtlFreeUnicodeString call. This call was an improper usage of the API and you can safely comment that line out.
Certain special locations on Win10, such as Quick Access, have been designed to deliberately break 3rd party programs such as this. They expose an ICategoryProvider, supply a default categorization key, but attempting to obtain the ICategorizer causes an error. This results in the folder not loading at all as a hard error like this wasn't handled. A workaround is available by adding the bolded lines around the following line in LVLoadFolder:
Code:
On Error Resume Next
pCatProvider.CreateCategory tSCGUID, IID_ICategorizer, pcppv 'pCatG '
On Error GoTo e0
This allows the folder to load, and items can be used. However, special properties (e.g. Pinned in Quick Access) are mostly unavailable, as Microsoft has apparently deliberately broken them; they'll load for one or two items but not all of them, which can only be explained by deliberately making it incompatible.
An app crash occurs if you refresh This PC 10 times or more. I'm investigating the cause. It may potentially be fixed in the current version (11.2) but I'm not confident enough to remove it yet.
Long-term issues with Windows or VB6 IDE
(Intentional Windows behavior, workaround available) When you run this program, or any program, as Administrator, in Windows 10 and above Mapped Network Drives do not show unless either you re-map them from an elevated process, or in Registry Editor, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System and create a new DWORD named EnableLinkedConnections and give it a value of 1. You can re-map the drives within ucShellBrowse (and ucShellTree) too: Navigate to the Desktop, then (if EnableShellMenu is True), right clicking 'This PC' will have the 'Map network drive...' option--- NOTE: While the mapping will appear in the dialog, complete it again anyway. After that, a Refresh will show the newly remapped drive going forward, in all apps, not just the one with ucShellBrowse.
(Not well understood, workaround) There may be an issue with the control going striped then appcrash after modifying other controls when there's two UserControls on the same form, similar to the last one. This time it appears to be APIs that are triggering it. I don't understand the precise cause or complete set of circumstances, so if this is a problem for you, for now just don't include any Public APIs in the module with your Sub Main.
Another triggering circumstance seems to be if an Enum value from the bas with Main is defined in the TLB but not the UserControl and used in the control.
(Unfixable, partial workaround) When OS zoom is set to other than 100% and dpiAware is not enabled in the manifest (or 'Disable display scaling on high-DPI settings' checked on the Properties->Compatibility tab), use of the shell context menu triggers graphical glitches. Subsequent right-clicks will have the menu pop-up nowhere near where clicked, and if running from the IDE all sorts of distortions in it.
There's no known fix for this issue, which effects numerous VB6 apps. If you use 100% scaling, it won't effect you, otherwise, the workaround is using the dpiAware=true or 'Disable scaling' options; ucShellBrowse is DPI-aware and scales itself.
(Unfixable, possible workaround) If you have 64-bit Microsoft Office installed and its msoshext.dll is the registered property handler for post-2007 Office files (typically those with an 'x' in the extension, .docx, .xlsx, etc), you will not be able to view/edit the custom properties like Author, Title, etc in the Details Pane or display columns. There does not seem to be any possible fix for this, as there's no way to load a 64-bit property handler from a 32-bit application; CoCreateInstance with the flags that are supposed to can't create the class. Nor is there a way to specify difference property handlers for 32bit apps vs. 64bit apps that I'm aware of. Only option would be to install 32bit Office instead for VB6. An alternative would be to use twinBASIC and the 64bit version of ucShellBrowse.
(Unfixable, no workaround) In a similar bug, while the control can load the Programs and Features control panel applet, it can only display the 32-bit programs.
Examples of Different Configurations and Features
Full, tight integration with the ucShellTree control.
New features: Showing the parent tree in the list (left), and loading the children of the selected folder in DirOnly/DirOnlyWithCtls modes (right).
You can configure it to be a simple thumbnail list, which includes thumbnails of embedded mp3 album art as shown on the right. Note that Windows doesn't come with a built-in FLAC handler, but if you install a 32-bit one, the control will be able to read/write those too.
Any property that's able to be edited can be set through the control, including through a popup date/time control or dropdown list where needed.
Multiple controls can be placed on the same form to create different layouts.
Turn the control into a Font Previewer. The root is set to the fonts folder; navigating elsewhere is disabled. Fonts with multiple styles appear in the dropdown, selecting them there or double clicking loads the list of individual styles for previews and info.
The Computer/This PC folder shows bars for the percent full in Details/Tile/Contents views, and automatically groups by drive type.
You can add a custom footer bar, and there's InfoTips that show a selection of properties, like Explorer does.
Progress marquee while loading folders
Popup frame that allows you to select columns. The picture on the left shows the frame as it initially appears. Shown on the right is the two advanced options: The filter bar, which lets you search for the property you want, and Advanced Mode-- This shows a whole bunch of properties not normally accessible as column options; because many of them are either not text, inapplicable to normal files/folders, or otherwise not suitable for being a display column. But many of them are valid as columns, such as the GPS properties shown above.
You can add entirely custom columns. An event is raised for each file giving the names/paths/shell interface to it, and you can specify the column data. As shown above, these custom columns have the option to support images.
You can specify a custom root, and browse FTP sites.
Certain columns have hyperlinks, this controls supports them.
Group by any property, and view the standard Explorer right-click context menu.
Custom font, tiled background, and no border.
Ratings stars, subsetted groups, custom foreground and background colors
Automatically populated Special Folders submenu for the Bookmarks menu.
You can open special locations like 'Devices and Printers' and 'Programs and Features', and use the right-click menu to carry out their custom actions like Uninstall a program, or Set As Default for a printer.
The search feature. You can start a quick search by just typing a string in the box on the form and pressing enter, or double-click the box to bring up the popup with additional options. You can optionally have the control box disabled, but have a menu item on right-click that brings up the popup (with additional box to type text in).
Notes
Using the control
The control can be used as either a regular UserControl, or can be compiled into an OCX. Since the control is now entirely self-contained, I recommend just adding the .ctl to your project. The control is added via the Project->Add UserControl menu option. Make sure ucShellBrowse.ctl and ucShellBrowse.ctx are in the same directory, but you only add the .ctl. As noted above, you need to go to Project->References and make sure oleexp.tlb (OLEEXP - Modern Shell Interfaces for VB6) is listed added as a reference when using the control this way, but once again, you need not distribute the typelib with your exe, it's only for the IDE.
Once added, you can add the control to a form and it will be created with the default options. The pictures at the top of this post, and in the post that follows, show the incredible diversity of the control. The major options you'll want to look at first include: ControlType - The default is 'Directory and Files', which shows the combobox with the folders dropdown, and the listview with the files. You can change that to Directories Only or Files Only, with the former having two additional modes, Drives Only, and Directories Only With Controls, which instead of being a plain combobox, also shows the Back/Forward, Up, View, Bookmarks, and Search Box controls-- all of which can be independently set to be shown or hidden (in the Directories Only mode, they're all hidden regardless of the individual settings, which is why this is a separate mode). ViewMode - This sets the initial view type of the ListView with the files. All modes are supported for startup: The default is Details, and the others are Small Icons, Medium Icons, Large Icons, XL Icons, Tiles, Content, List, or Thumbnails (size set via ThumbnailSize option). Not all modes can be viewed in the IDE Design Mode, but will be when the program runs. BrowserPath - The value entered here will be used for startup. It defaults to App.Path. There's also the following options: BrowserStartLast (start in the last path the control was viewing; uses the BrowserPath value the first time), or BrowserStartBlank, to not load any folder. ComboType and ComboCanEdit - The default is a typical dropdown, but you can change it to DropdownList or Simple. Allowing editing permits typing in a full path, a folder name in the current path, environmental variable shortcuts, or custom shortcuts (see the ValidateTextNavigate event). There's also the AutoComplete option, which is available but disabled by default. CustomRoot, CustomRootLocked, and ComputerAsRoot - By default, the directory dropdown, like Explorer, has its root as the Desktop. You can change that to Computer (This PC in Win10) with the ComputerAsRoot option, or specify an entirely custom path. The custom path can be anywhere the control can navigate, including special locations, network locations, and FTP addresses. The CustomRootLocked option will limit browsing to the root folder and its children, not allowing the user to navigate anywhere else in the file system.
So those are the major options to look at when first configuring the control. After that, there's many, many other options from the color options, to layout options for all the individual elements, to numerous details about how the file view works. You'll want to read through each option, they all have descriptions that describe what they do.
Compiling to OCX
It's very simple to use the control as an OCX: Open ShellBrowse.vbp from the main folder, in the properties for the control, change Public to True, you can then compile. Then proceed to move, register, and use as you would any other .ocx. A project with the OCX does not require oleexp.tlb. If needed I could also send the compiled OCX, just ask here or PM.
The demo projects use the control as a .ctl.
Multiple Controls
You can have more than one ucShellBrowse on a form. If you want to have them linked, like one with the directory dropdown only, then one with files only elsewhere on the form, you'll need to change the path in one when the other changes:
Code:
Private Sub ucShellBrowse1_DirectoryChanged(ByVal sFullPath As String, siItem As oleexp.IShellItem, pidlFQ As Long)
ucShellBrowse2.BrowserOpenItem siItem
End Sub
Private Sub ucShellBrowse2_DirectoryChanged(ByVal sFullPath As String, siItem As oleexp.IShellItem, pidlFQ As Long)
ucShellBrowse1.BrowserOpenItem siItem
End Sub
Note: This section previously indicated usage of a variable to detect if a manual change was happening to prevent an infinite loop, but that need was eliminated by adding a sanity check to the control many versions ago now, so all you need is the above.
Also, to make sure virtual objects are navigated correctly, it's best to use BrowserOpenItem instead of BrowserPath.
Printing Directory List
This is a pretty common usage, which is why I added the simple .Files(), .Folders(), etc. But what if you want to output a fancy list:
This is done in a project form rather than the .ctl. First, add oleexp addons mIID.bas and mPKEY.bas (if copying from here; the demo project in the zip has its own copies of the needed UUIDs/PKEYs). Second, in a module we'll borrow some support code from the control:
Code:
'(See Form1 in the Demo folder for the 3 API declares used below if you don't already have them.)
Public Function LPWSTRtoStr(lPtr As Long, Optional ByVal fFree As Boolean = True) As String
SysReAllocString VarPtr(LPWSTRtoStr), lPtr
If fFree Then
Call CoTaskMemFree(lPtr)
End If
End Function
Public Function GetPropertyKeyDisplayString(pps As IPropertyStore, pkProp As oleexp.PROPERTYKEY, Optional bFixChars As Boolean = True) As String
'Gets the string value of the given canonical property; e.g. System.Company, System.Rating, etc
'This would be the value displayed in Explorer if you added the column in details view
Dim lpsz As Long
Dim ppd As IPropertyDescription
PSGetPropertyDescription pkProp, IID_IPropertyDescription, ppd
If ((pps Is Nothing) = False) And ((ppd Is Nothing) = False) Then
PSFormatPropertyValue ObjPtr(pps), ObjPtr(ppd), PDFF_DEFAULT, lpsz
SysReAllocString VarPtr(GetPropertyKeyDisplayString), lpsz
CoTaskMemFree lpsz
If bFixChars Then
GetPropertyKeyDisplayString = Replace$(GetPropertyKeyDisplayString, ChrW$(&H200E), "")
GetPropertyKeyDisplayString = Replace$(GetPropertyKeyDisplayString, ChrW$(&H200F), "")
GetPropertyKeyDisplayString = Replace$(GetPropertyKeyDisplayString, ChrW$(&H202A), "")
GetPropertyKeyDisplayString = Replace$(GetPropertyKeyDisplayString, ChrW$(&H202C), "")
End If
Set ppd = Nothing
Else
Debug.Print "GetPropertyKeyDisplayString.Error->PropertyStore or PropertyDescription is not set."
End If
End Function
Then we get to the code to do it. Before calling this, do Select All (Ctrl+A) manually (since there's no other way in this version to get an array of all items)... then with everything selected:
Code:
Private Sub Command3_Click()
On Error GoTo e0
Dim pArSel As IShellItemArray
Dim siChild As IShellItem, si2 As IShellItem2
Dim pst As IPropertyStore
Dim nItems As Long
Dim lpsz As Long, sTmp As String
Dim sOut As String
Dim dwAtr As SFGAO_Flags
Dim i As Long
Set pArSel = ucShellBrowse1.SelectedItems
pArSel.GetCount nItems
Debug.Print " Name Size Date Modified Attributes"
Debug.Print "---------------------------------------------------------------------------"
For i = 0 To (nItems - 1)
pArSel.GetItemAt i, siChild
If siChild Is Nothing Then
Debug.Print "No child"
Exit Sub
End If
Set si2 = siChild
siChild.GetAttributes SFGAO_FOLDER, dwAtr
If (dwAtr And SFGAO_FOLDER) = SFGAO_FOLDER Then
sOut = "<DIR> "
Else
sOut = " "
End If
siChild.GetDisplayName SIGDN_NORMALDISPLAY, lpsz
sTmp = LPWSTRtoStr(lpsz)
sOut = sOut & sTmp
sOut = sOut & Space$(30 - Len(sOut))
si2.GetPropertyStore GPS_OPENSLOWITEM Or GPS_BESTEFFORT, IID_IPropertyStore, pst
sTmp = GetPropertyKeyDisplayString(pst, PKEY_Size)
sTmp = Space$(13 - Len(sTmp)) & sTmp & " "
sOut = sOut & sTmp
sTmp = GetPropertyKeyDisplayString(pst, PKEY_DateModified)
sTmp = sTmp & Space$(20 - Len(sTmp))
sOut = sOut & sTmp
sTmp = GetPropertyKeyDisplayString(pst, PKEY_FileAttributes)
sTmp = "-" & sTmp
sOut = sOut & sTmp
Debug.Print sOut
Set pst = Nothing
Next i
pArSel.GetPropertyStore GPS_BESTEFFORT Or GPS_OPENSLOWITEM, IID_IPropertyStore, pst
If (pst Is Nothing) = False Then
sTmp = GetPropertyKeyDisplayString(pst, PKEY_Size)
Set pst = Nothing
Else
sTmp = ""
End If
Debug.Print "---------------------------------------------------------------------------"
Debug.Print " " & nItems & " items " & sTmp
Exit Sub
e0:
Debug.Print "Form1.Command3_Click->Error: " & Err.Description & ", 0x" & Hex$(Err.Number)
End Sub
Changing to text output is just a matter of replacing Debug.Print with a write to a text file.
Localization
This project contains a large number of English-language strings, which presents a problem for users who speak another language. The code in Version 5.3 was reorganized to make localization as easy as possible: all of the text* is located in one place; near the top of the control in the User Consts section just below the changelog. Control captions are set from this section as well. So for example, to turn the whole thing French-
Code:
'Control captions:
Private Const scc_Up = "Haut"
Private Const scc_Back = " Retour"
Private Const scc_Forward = "Svnt"
Private Const scc_View = "Vue"
Private Const scc_Ok = "OK"
Private Const scc_Cancel = "Annuler"
Private Const scc_Save = "Enreg."
Private Const scc_ChCols = "Colonnes"
Private Const scc_Prv = "Aperçu"
Private Const scc_Width = "Largeur"
Private Const scc_PropCol = "Propriétés"
'These are applied to the controls always; changing the caption in the Properties window has no effect at runtime.
Private Const mn_sMore As String = "Plus..." 'There's no system resource to load localized translations like the other items
Private Const mn_sLock As String = "Garder memes colonnes" 'on the column menu, so you may change it manually here if you wish
'Note: The lock item won't appear if columns are locked through the LockColumns property
Private Const mn_sLW = "Bloquer largeur"
Private Const mn_sLH = "Bloquer hauteur"
Private Const mn_sSel = "Selectionner"
Private Const mnv_sGrpHdr = "Grouper par"
Private Const mnv_sSortHdr = "Trier par"
Private Const mnv_sSortAsc = "Ordre croissant"
Private Const mnv_sSortDsc = "Ordre décroissant"
Private Const mnv_sli As String = "Grandes Icônes"
Private Const mnv_sSM = "Petites Icônes"
Private Const mnv_sLS = "Liste"
Private Const mnv_sDT = "Détails"
Private Const mnv_sTV = "Tuiles"
Private Const mnv_sCT = "Contenu"
Private Const mnv_sJM = "Vignettes"
Private Const mnv_sNN = "(aucun)"
Private Const mnv_sNF = "Nouveau dossier"
Private Const mnv_sPR = "Propriétés"
Private Const mnv_sRF = "Rafraîchir"
Private Const mnv_sSB = "Barre d'état"
Private Const mnv_sPV = "Volet aperçu"
Private Const mnv_sDB = "Barre de détails"
Private Const mnv_sPS = "Collez"
Private Const mnv_sBK = "Signets"
Private Const m_def_GroupSubsetLinkText As String = "Plus de fichiers..."
Private Const m_sColCap As String = "Choisir des colonnes"
'(and so on. A number of strings have been omitted because of the post character limit, and before that it was many versions out of date anyway. Please consult the control itself for remaining items to translate.)
Since I don't want to make a particular resource file mandatory, I didn't set this up as a string table in one, but you could easily set that up too with everything in one place like this. Did the best I could for the circumstances.
And please forgive me if I got something wrong in my example, I was nearly fluent but haven't used French in about 13 years now.
* - The column names in the ListView, and the column data itself, are loaded from Windows, and thus will already appear in whatever the current system language is.
UPDATE: As of Version 8.0, all images are now built into the control. You no longer need to worry about keeping them together, you only need the .ctl and .ctx. The alternative manifest for the demo with DpiAware set to False is now included in the main download. It's now possible to simply add the .ctl to your project with an existing resource/manifest, and nothing else need be done. No more separate images! Thanks go to LaVolpe and The_trick.
Image Encoder
As per above, the icons have been encoded into the .ctl. The binary data from the icons was encoded into a bitmap, which could then be set as the image for a picturebox, and then be decoded back to binary data and processed as an icon/png file. All of the default icons are now built into the control as images in a picturebox that are decoded to binary data. If you wish to add additional images to the control (or use the method in your own project), I'm attaching the tool I developed around The_trick's code. The decoding function is also included but not used. There are no dependencies. You do not need to have this or do anything with this to run the control complete with the default images, just to add additional images beyond the ones it comes with, or to replace the images already contained in it.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Nice start. This is going to be very useful. Some feedback from running your demo:
1 - The preview pane is slightly larger than the details pane and it covers the top bit of the status bar.
2 - It would be very nice to be able to drag between the details and preview panes to resize both together in the x-axis.
3 - The button to the right of the Back button never is fully displayed even if the overall window is dragged to the right. I can't tell what the text in the box is although I can see a check mark displayed in the box.
4 - When I cycle through large icons, small icons, etc. by the time I get back around to Details the column headers are there but no text is shown except in the first column.
Last edited by MountainMan; Oct 30th, 2017 at 09:44 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Public Methods
The Properties all appear in the Properties Box and have descriptions attached to them, so here's the same thing for public Subs, Functions, and runtime Properties (ones that do not appear in the Properties Box). List is complete as of v11.0.
Functions & Subs
AddColumn
Manually add a column to Details View by a system property name, e.g. System.DateModified
AddColumnByPKEY
Same as above, except by PROPERTYKEY. Since you cannot pass one directly, pass VarPtr(pkey)
AddCustomColumn
Adds a custom column with the specified options. An event is raised to ask for item data.
AppendCustomFolder
If you're displaying a custom folder, adds an additional file or folder.
AutocompleteFlagAdjust
For changing the default autocomplete flags, both AUTOCOMPLETEOPTIONS and AUTOCOMPLETELISTOPTIONS.
Bookmarks (Get/Let)
Manually view or set the bookmarks data, format: path1|path2|path3 etc
BrowserOpenItem
Navigate to a location represented by an IShellItem
BrowserPathItem (Get/Let)
Gets an IShellItem reference for the current location or navigates to the one passed.
BrowserPathPidl (Get/Let)
Set or retrieve the current location by fully qualified PIDL
ClearSelection
Deselects all ListView items
ComboSetFontByHandle
Set the ComboBox font directly by HFONT
ComboSetFontOLE
Set the ComboBox font directly by HFONT
ControlBarHeight
Returns the current height of the control bar.
CreateCustomFolder
Adds a folder with a set of manually given files from anywhere on the system. May only have one, but search results are separate.
DebugLogInsertMessage
If debug logging is enabled, manually insert an entry.
DetailsPaneHeight (Get/Let)
Get or manually set the height of the Details Pane.
DetailsPaneHeightLocked (Get/Let)
Sets whether the user can adjust the height of the Details Pane.
DetailsPaneWidth (Get)
Retrieves the width of the Details Pane.
DialogGUID (Get/Let)
The 'Custom' button in the built-in search footer bar loads a common dialog, set a unique GUID to prevent the last path chosen in it from being the last path for any common dialog your app opens, or to share one between controls. More details.
DisplayCustomFolder
If a custom folder has been created with CreateCustomFolder, opens it.
DPIScaleX (Get/Let)
Retrieve or manually set the current DPI scaling factor for width.
DPIScaleY (Get/Let)
Retrieve or manually set the current DPI scaling factor for height.
ExecFileSearch
Initiates a custom search in the current folder for the specified patttern.
ExecFileSearchEx
Initiates a custom search with an IShellItem location and ICondition search parameters object.
FileCount
A function that returns the number of files (does not include folders, or zip files if zip navigation is enabled)
FileGetCheck
Specifies if the given file or folder name (in the current folder, name only) is checked.
FileGetProperty
Returns the property, by system name (e.g. System.Keywords), for the given file or folder (in the current folder, name only)
FileGetPropertyByPKEY
Same as above, except by PROPERTYKEY. Pass VarPtr(pkey)
FileItemFromPos
Returns an IShellItem for the file at the specified numerical position in the file list.
FilePathFromPos
Returns the full path for the file at the specified numerical position in the file list.
Files()
Returns an array of the file names (but not folders) in the current directory.
FilesChecked()
Returns an array of the file that are checked (file names only).
FilesCheckedCount
Returns a count of all files (excluding folders) that are checked.
FilesCheckedFull()
Returns an array of the files that are checked (full paths).
FilesSelected()
Returns a list of only the selected files (i.e. selected folders not included)
FilesSelectedCount (Get)
The number of files, excludes folders.
FilesSelectedFull()
The full paths version of the above.
FileSetCheck
Sets (1) or clears (0) the check status of a given file or folder by name (current folder, by name only).
FilesFullParsing()
Returns an array of full paths for files (not folders) in the current directory. Can specify a filter.
FilterBarApplyManually
Simulates typing something into the Filter Bar (whether or not it's currently shown).
FolderCount
A count of folders, including zip files if zip navigation enabled, in the current directory.
Folders()
Returns an array of all folder names in the current directory.
FoldersChecked()
Returns an array of all folder names that are checked.
FoldersCheckedCount
Returns a count of all folders that are checked.
FoldersCheckedFull()
Returns an array of all folder full paths that are checked.
FoldersFullParsing()
Same as above, only full paths.
FoldersSelected()
Returns a list of only the selected folders (i.e. selected files not included)
FoldersSelectedCount (Get)
Returns a count of only the selected folders (i.e. selected files not included)
FoldersSelectedFull()
The full paths version of the above.
FooterAddButton
Adds a button to an already existing footer bar.
FooterClearButtons
Removes all buttons from the footer bar.
FooterCreate
Creates a footer bar at the bottom of the file list (undocumented ListView feature).
FooterRemove
Removes the footer bar.
GetCurrentColumnCount
Retrieve the current column count.
GetCurrentColumns
Retrieves the information about currently displayed columns.
GetGroupColumn
Gets the column index that files are grouped by; returns -1 if grouping is disabled.
GetHistoryData
Retrieves the history buffer for the control's History menu and Back/Forward.
GetPidlStoreEntry
The control keeps a list of fully qualified pidls for each path loaded, this retrieves one by path.
GetSortColumn
Retrieves the column that items are currently sorted by.
GetSortDirection
Retrieves whether sorting is ascending or descending.
GroupCollapseGroups
Sets if a group (or all groups if you pass -1 as the index) is collapsed (0) or not (1).
GroupSetIcon
Assigns the given icon in the system image list to a group header.
HighlightColumn
Highlights the given column by index in the specified color.
HighlightColumnByProperty
Same but you identfy the column by its property (system name, e.g. System.Size)
hWnd_______ (Get)
Retrieves the hWnd of various components of the control (separate propgets for each rep'd by blank).
InvokeColumnSelection
Brings up the dialog box for choosing columns.
InvokeGroupByColumn
Group items by the given column index.
InvokeGroupByPKEY
Group items by the given PROPERTYKEY (passed by VarPtr(pkey)).
InvokeInvertSelection
Inverts which items are selected.
InvokeNewFolder
Creates a new folder and initiates a label edit to rename it.
InvokeSelectAll
Select all items.
InvokeSortAscending
Sorts items in ascending order of the current sort column.
InvokeSortByColumn
Sort items by the given column index.
InvokeSortByPKEY
Sort items by the given PROPERTYKEY (passed as VarPtr(pkey)).
InvokeSortDescending
Sorts items in descending order of the current sort column.
ItemIsFolder
Determine if a file-view item is a folder by position, name, or full path.
Items()
Returns a list of both file and folder names.
ItemsChecked()
Returns a list of both file and folder names which are checked.
ItemsCheckedCount
Returns the total number of files+folders checked.
ItemsCheckedFull()
Returns a list of both file and folder full paths that are checked.
ItemsFullParsing()
Returns a list of both file and folder full paths.
ItemsSelected()
Returns a list of both selected file and folder names.
ItemsSelectedCount
Returns the total number of files+folders selected.
ItemsSelectedFull()
Returns a list of the full paths of all selected files and folders.
ListViewSetFontByHandle
Set the ListView font directly by HFONT
ListViewSetFontOLE
Set the ListView font directly by StdFont
LogActive (Get/Let)
Sets whether the debug log file output is active.
NavGoBack
Navigate to the previous directory.
NavGoForward
Navigate forward through history if available.
NavOpenParent
Navigate to the parent of the current location ('Up')
PictureSetByHBITMAP
Sets a background image in the file list by passing an HBITMAP.
PictureSetByURL
Same as above but by URL.
PreviewPaneHeight (Get)
Gets current Preview Pane height.
PreviewPaneWidth (Get/Let)
Retrieve or manually set the width of the Preview Pane.
PreviewPaneWidthLocked (Get/Let)
Sets whether the user can adjust the width of the Preview Pane.
RedrawList
Redraws the list items without reloading the folder (useful for color changes).
RefreshPreview
Reloads the contents of the Preview Pane
RefreshTree
Rebuilds the directory dropdown. Only the current location will remain expanded (besides defaults).
RefreshView
Reloads the current location.
RemoveColumnByPKEY
Manually remove the specified column.
RemoveColumnByPropName
Manually remove the specified column.
RemoveCustomColumn
Manually remove the given custom column.
ScaleHeight (Get)
Returns the ScaleHeight of the control.
ScaleWidth (Get)
Returns the ScaleWidth of the control.
SelCount (Get)
Returns the number of items selected.
SelectedColumn (Get/Let)
The currently selected (i.e. last clicked) column.
SelectedFile (Get/Let)
The currently selected (and focused, if multisel) file name.
SelectedFileGetProperty
Gets a property of the currently selected (and focused if multisel) file by system name.
SelectedFileGetPropertyByPKEY
Same but by PROPERTYKEY. Pass VarPtr(pkey).
SelectedFilePath (Get)
Full path to selected (and focused, if multisel) file.
SelectedFiles (Get/Let)
A Variant array of selected file names or file names to select.
SelectedFilesCount (Get)
The number of files, excludes folders.
SelectedFilesPaths (Get)
String array of full paths of selected files.
SelectedFileSet
Provides expanded options for setting the selected file: Deselect others, ensure visible, and set focus.
SelectedItem (Get)
An IShellItem reference to the currently selected (and focused if multisel) file.
SelectedItems (Get)
An IShellItemArray of all selected items.
SetAdvancedStringSort
Use CompareStringEx with the given params instead of StrCmpLogicalW
SetCustomComboImageList
Set an alternate imagelist for the dropdown. (Setting items not yet implemented)
SetCustomListViewImageLists
Set an alternate imagelist for the ListView. (Setting items not yet implemented)
SetFocusOnDropdown
Sets focus on the folder dropdown combobox.
SetFocusOnFiles
Sets focus on the file ListView
SetPreviewPictureWithHBITMAP
If the Preview Pane is active, manually set what it shows by HBITMAP
SetPreviewPictureWithHICON
Same as above but with HICON
SetPreviewPictureWithStdPic
Same as above but with StdPic object.
SetSelectedItemsEx
Allows selecting files by pattern (e.g. *.exe) and provides expanded options for selections including deselect previous and ensure visible. Can be applied to only files, only folders, or both.
ShellTreeStatus (Get/Let)
If you're using the ShellTreeInLayout option, set/retrieve whether the item is checked.
ShowSecurityZone
Adds a StatusBar panel that shows the Security Zone icon+label for the current locationL Computer, Local Intranet, etc. Both are loaded from Windows. (This is a property, but the desc is blank, so temporarily listing it here.
StartLoadingMarquee
Manually turns on the progress marquee in the combobox.
StopLoadingMarquee
Manually turns off the progress marquee in the combobox.
StatusBarHeight (Get/Let)
Set/Get the current status bar height.
StatusText (Get/Let)
Set/Get the current status bar text.
UpdateStatus
Manually set a status bar message. The difference from the above is the ability to set the 2nd panel (if present).
Events
BackgroundKeyDown
KeyDown when the control has focus but none of the controls on it do.
BackgroundKeyUp
KeyUp when the control has focus but none of the controls on it do.
Click
Click on the control background, not on a dropdown/list/button/etc.
ComboCloseUp
When the directory dropdown closes up.
ComboDropdown
When the directory dropdown list opens up.
ComboEditChange
When the text in the directory dropdown edit box changes.
ControlTypeChange
Notifies you of control changes between Files Only, Files+Dir, Dir/Drv Only, and Dir Only + Ctls
CustomColor
Allows you to set the fore- and back- color of any item or subitem. Overrides the regular color setting.
CustomColumnQueryData
Identifies a custom column and the item being set with a return for the desired text and, optionally, image index.
DblClick
Click on the control background, not on a dropdown/list/button/etc.
DebugMessage
Provides your form with a copy of the debug output.
DetailsPaneHeightChanged
Notifies you that the height of the Details Pane has changed.
DirectoryChanged
Fires after a directory change is complete. Note: Do not free the pidl referenced here.
DragStart
Gives file list / key state of a drag operation.
DropFiles
Passes a string array with the files passed on a drop operation.
EnterFocus
Control received focus.
ExitFocus
Control lost focus.
FileCheck
Gives the index, name, and check value of a file when it's check/unchecked
FileClick
Gives a clicked files name, IShellItem reference, and which button clicked it.
FileDetailsWrite
Raised when a file property is written with the Details Pane. Includes file name, property, and new value.
FileExecute
Gives the file name and IShellItem reference of a file when double-clicked or Enter pressed.
FileRenamed
Raised with the old name and new name.
FileSearchPopup
Notifies the host that a search has started, and includes all the details of the search.
FileSearchStart
Notifies the host that a search has started, and includes all the details of the search.
FilterBarOverride
The Filter Bar has its own matching setup, but you can substitute your own using this event.
FilterFile
Allows a custom choice on whether or not to show each file. Will override ItemFilter.
FilterFolder
Same as above for folders. Will override ItemFilterFolder.
FooterButtonClick
Gives the index and lParam of a clicked footer button.
ItemAdded
Raised with the name of an added file.
ItemLinkClick
Raised when a link from a hyperlink column is clicked.
ItemRemoved
Raised with the name of a file that was removed from the list (deleted, moved, etc).
ListKeyDown
Passes the key pressed and provides an option to disable internal handling of it.
ListKeyUp
Notifies when a KeyUp event occurs from the ListView.
MouseDown
Click on the control background, not on a dropdown/list/button/etc.
MouseMove
Same as above.
MouseUp
Same as above.
PreDirectoryChange
Fires immediately before the loading process for a new location begins. Allows cancelling the navigation.
PreviewPaneWidthChanged
Notifies you of a change in the Preview Pane width.
QueryCustomIcon
Supply a custom icon when the view mode is SB_VIEW_CUSTOM.
QueryCustomIconOverlay
Supply a custom overlay icon when the view mode is SB_VIEW_CUSTOM.
QueryCustomInfoTip
Supply a custom infotip (similar to a tooltip) if that option has been selected for InfoTipMode.
SelectionChanged
Provides a string array of all selected items, a string of the focused item, and an IShellItem for the focused item.
SelectionCleared
Raised when the selection changes to nothing selected.
ShowShellTree
If you're using the ShellTreeInLayout option, notifies when the user toggles the menu item for it.
SortItems
Provides various details about each sort operation.
StatusMessage
Provides a copy of any message going to the StatusBar, e.g. in case you don't have it enabled and want to display it elsewhere.
ToggleDetailsPane
Notifies you that the Details Pane has been shown or hidden.
TogglePreviewPane
Notifies you that the Preview Pane has been shown or hidden.
ToggleStatusBar
Notifies you that the StatusBar has been shown or hidden.
ValidateTextNavigate
When editing in the Dropdown is enabled, allows replacing some or all of the text to e.g. implement shortcut keywords.
ViewChanged
Details, Large Icon, Tile, etc.
Last edited by fafalone; Jan 25th, 2022 at 01:02 AM.
Reason: Updated Public Methods/Events for current version
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Here is how the form looks like when I first run your sample:
and here is what the form looks like when I dragged the bottom right to show more of the form (I also drug the date/time column header to the right to show file date/times):
I am running Windows 10 and have a scaling factor of 175% set. I'll run this on another machine later where the scaling factor is set to 100% and let you know how it looks.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Does this support custom/virtual data sources in any way? That getting file lists not tied to the file system?
I ask because I have a bunch of data with hashed file names stored on the file system, but with virtual links to those files in a database and custom "file names". I'm thinking about implementing something where users can browse the database of links just like explorer, and I'm curious if your demo would be useful for something like that.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Reply to Post #3:
Thanks for the feedback. For #3, you're talking about the View button right (refer to the picture in the main post)... is the option to show the View button enabled, and are you on standard DPI (I haven't checked anything regarding DPI sensitivity yet), and OS version? I'll have to take a more thorough look since as the picture indicates, it appears normally on my system.
With #4, does refreshing fix the issue? I've had to add a couple refreshes for things like that before, it usually works. If not, does changing directories fix it? Or adding/hiding a column? I'll take a look myself of course but additional feedback always helps.
Originally Posted by MountainMan
Here is how the form looks like when I first run your sample:
and here is what the form looks like when I dragged the bottom right to show more of the form (I also drug the date/time column header to the right to show file date/times):
I am running Windows 10 and have a scaling factor of 175% set. I'll run this on another machine later where the scaling factor is set to 100% and let you know how it looks.
Ah, definitely a DPI scaling issue then. None of the scaling adjusts for that yet; I'll do it for the next version though, I'm more familiar with it now and it worked out pretty well after making the TaskDialogIndirect project work with different DPI.
Edit: Regarding the View switching, can you confirm, the only time a problem arises is when Thumbnail view is activated and then switched out of? Thumbview changes the imagelist and item icon indecies, so to fix it I restored those in the switchout. I have no idea why the details weren't showing in the columns, but calling a refresh after the switchout restores them.
Originally Posted by jpbro
Does this support custom/virtual data sources in any way? That getting file lists not tied to the file system?
I ask because I have a bunch of data with hashed file names stored on the file system, but with virtual links to those files in a database and custom "file names". I'm thinking about implementing something where users can browse the database of links just like explorer, and I'm curious if your demo would be useful for something like that.
Thanks!
I'm not sure there's anything that would benefit over starting from scratch; there's very little in the project that does any manual file handling, it's all back and forth with the shell. I'm not entirely sure the format you mean though; if you just wanted to replace the file system names with one looked up from a database, that would be easy enough, just a couple lines in the enumerator (and would work out well, since the display name is largely unconnected to anything about the file)... if that's not an accurate picture of what you're doing can you clarify?
Last edited by fafalone; Dec 15th, 2019 at 01:39 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Hi fafalone,
Sorry for not getting back to you sooner, I missed your reply.
Here's a better explanation of my situation.
I have some called "Projects" and each project has a name (basically a database table).
Each project can have sections, say "A" to "J".
Each section can have items (unlimited, identified by a GUID).
Each item can have attachments (again unlimited, identified by a GUID, a file hash, and with a human readable title).
Attachments are things like PDF and image files. They are stored on the file system in a series of subfolders based on the first 4 characters of their file hash. A single attachment can be linked to multiple items across multiple sections and projects, but it will only be stored on the file system once and only a link is recorded in the project database.
So what I would like to do is have a browsable shell/explorer-like interface that let's users pick a project and it will show all of the attachments for that project. Columns might be SECTION, ITEM, TITLE, SIZE, FILETYPE, PHYSICAL LOCATION, HASH. Physical locations can of course then be duplicated across multiple attachments as long as the linked item is different.
So a file with a hash of ABCDEFGHIJKLMNOP would be stored somewhere C:\ProgramData\MyApp\Attachments\A\B\C\D\ABCDEFGHIJKLMNOP, but it is linked in project A, Section 2, Item QRSTLMN as well as Project A, Section 4, OPQRSTU. I would like to show both entries but customize the text that appears for all column/cells to the friendly human readable forms.
Would such a thing be possible with your demo? I'm willing to do the work to modify it, just wondering if I should even bother to try.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Ok so I think I understand how you would want this to work... you would be able to generate a list of shell locations (full file paths) for the current items attachments, then you just want to display those in the ListView? And since it's a fixed list, you wouldn't need navigation ability right?
If that's an accurate assessment of the functionality, then to load an arbitrary list of files in different locations like that, I don't think starting with this project would be the best route to go. However, another project of mine, Advanced Thumbnail ListView, could very easily be modified to show such a list-- despite the project being about thumbnails, before thumbnail mode is activated, it loads a file system folder with normal icons that you could change to most of the other views without effort. The enumeration method in that project would be able to be modified to load an arbitrary list instead quite easily, and would be much easier to have a fixed, custom set of details columns (set just like the first column but with the .iSubItem filled in). Then, taking any other Explorer-type functionality you might need could be transplanted from this project (like if you wanted the right-click context menu from Explorer, the preview pane, or the drag and drop features, etc). I really think going that direction would be more efficient than re-doing the loading/navigation/details system in this project, because it's so thoroughly bound to the shell.
Edit: General Update on 2018-01-17
Haven't stopped developing this project, it's just very complicated to add the latest set of features... added over 2,000 lines to the project since the first release New: Details pane (multi-item, background, read/write strings), Active drag/drop, disable d/d option, browse in Zip, add/remove/update file list in response to shell change notify*, resize preview pane, autotoggle control box at small widths, all reported and several unreported bugfixes
At this point, the next version is feature-complete; going to hold over detail pane editing for non-string and tree updating (see note below) for a future version.
All that remains is final testing. Surprisingly no adjustments needed to be made for DPI.
*-The tree dropdown isn't updated; this would require monitoring the entire filesystem and be much more trouble than it's worth
Last edited by fafalone; Jan 17th, 2018 at 11:40 PM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
v2 is feature-complete, so I thought I'd post it as a beta release for anyone else interested to test too.
Test Updates
Glad I didn't post this as a final...
-FileDragDropMode Property Let has an error, Detach shouldn't have an argument.
-Subclassing the edit boxes for properties seems to be stable, so I'm going to go that way after all. That means the Save/Cancel buttons will automatically appear without the need of clicking a picture, when you type a char
-Since it's subclassed now, going to include the ability to change dates too, popping up a datetime control on click, presuming it saves ok when I get to that part (working with PROPVARIANT is a pain to begin with, VT_FILETIME being unsupported without PropVariantToVariant doubly so; that works for reading it, hopefully I can get it to save). Edit: Confirmed working! Used InitPropVariantFromFileTime.
-Like the Date Control above, there's also pop-up combobox controls for editable properties that are a list.
Just getting the list items is crazy:
Code:
If tDispProps(nDispProp).dwDispType = PDDT_ENUMERATED Then
On Error GoTo e1
DebugAppend .szSystemName & " type=0x" & Hex$(tDispProps(nDispProp).dwDispType)
pps.GetValue .pkey, vrp
PropVariantToVariant vrp, vrpvb
DebugAppend "Value=" & CStr(vrpvb)
tDispProps(nDispProp).vEnumeratedValue = vrpvb
DebugAppend "VarType=" & VarType(vrpvb)
If VarType(vrpvb) = vbEmpty Then
tDispProps(nDispProp).vEnumeratedIsEmpty = True
End If
' GoTo skipenum
Dim ppd As IPropertyDescription
PSGetPropertyDescription .pkey, IID_IPropertyDescription, ppd
Dim pETL As IPropertyEnumTypeList
Dim pET As IPropertyEnumType
Dim nEnumType As PROPENUMTYPE
Dim lpInitIdx As Long
Dim nTCt As Long
Dim vr1 As Variant, vr2 As Variant, vr3 As Variant, vr4 As Variant
Dim vb1 As Variant, vb2 As Variant, vb3 As Variant, vb4 As Variant
Dim lpTemp As Long, sTemp As String, l1 As Long, l2 As Long, s1 As String, s2 As String
ppd.GetEnumTypeList IID_IPropertyEnumTypeList, pETL
If (pETL Is Nothing) = False Then
DebugAppend "Got ETL for " & .szSystemName
pETL.GetCount nTCt
If nTCt > 0 Then
DebugAppend "typect=" & nTCt
ReDim tDispProps(nDispProp).sEnumerated(nTCt - 1)
ReDim tDispProps(nDispProp).vEnumerated(nTCt - 1)
For j = 0 To (nTCt - 1)
pETL.GetAt j, IID_IPropertyEnumType, pET
If (pET Is Nothing) = False Then
pET.GetEnumType nEnumType
DebugAppend "nEnumType=" & nEnumType
If nEnumType = PET_DEFAULTVALUE Then
pET.GetDisplayText lpTemp
DebugAppend "PET_DEFAULTVALUE str=" & LPWSTRtoStr(lpTemp)
End If
If (nEnumType = PET_DISCRETEVALUE) Then
pET.GetRangeMinValue vr1
pET.GetRangeSetValue vr2
PropVariantToVariant vr1, vb1
PropVariantToVariant vr2, vb2
DebugAppend "PET_DISCRETEVALUE v1=" & CStr(vb1) & ",v2=" & CStr(vb2)
pET.GetValue vr3
PropVariantToVariant vr3, vb3
DebugAppend "PET_DISCRETEVALUE vr3=" & CStr(vb3)
pET.GetDisplayText lpTemp
tDispProps(nDispProp).sEnumerated(j) = LPWSTRtoStr(lpTemp)
tDispProps(nDispProp).vEnumerated(j) = vr3
DebugAppend "PET_DISCRETEVALUE str=" & tDispProps(nDispProp).sEnumerated(j)
If tDispProps(nDispProp).vEnumeratedIsEmpty = False Then
DebugAppend "Comp " & CLng(tDispProps(nDispProp).vEnumeratedValue) & "|" & CLng(vb1)
If CLng(tDispProps(nDispProp).vEnumeratedValue) = CLng(vb3) Then
tDispProps(nDispProp).lEnumeratedInitialIndex = j
End If
End If
End If
If (nEnumType = PET_RANGEDVALUE) Then
pET.GetRangeMinValue vr1
pET.GetRangeSetValue vr2
PropVariantToVariant vr1, vb1
PropVariantToVariant vr2, vb2
DebugAppend "PET_RANGEDVALUE v1=" & CStr(vb1) & ",v2=" & CStr(vb2)
pET.GetDisplayText lpTemp
tDispProps(nDispProp).sEnumerated(j) = LPWSTRtoStr(lpTemp)
If CLng(vb2) = 0& Then
tDispProps(nDispProp).vEnumerated(j) = vr1
Else
tDispProps(nDispProp).vEnumerated(j) = vr2
End If
tDispProps(nDispProp).vEnumeratedIsRanged = True
DebugAppend "PET_RANGEDVALUE str=" & tDispProps(nDispProp).sEnumerated(j)
If tDispProps(nDispProp).vEnumeratedIsEmpty = False Then
If CLng(tDispProps(nDispProp).vEnumeratedValue) >= CLng(vb1) Then
tDispProps(nDispProp).lEnumeratedInitialIndex = j
End If
End If
End If
If nEnumType = PET_ENDRANGE Then
pET.GetValue vr3
pET.GetRangeMinValue vr4
PropVariantToVariant vr3, vb3
PropVariantToVariant vr4, vb4
DebugAppend "PET_ENDRANGE v3=" & CStr(vb3) & ",v4=" & CStr(vb4)
tDispProps(nDispProp).vEnumeratedEndRange = vr3
End If
End If
Next j
Else
DebugAppend "typect=0"
End If
End If
End If
Update (Jan31)
Removed beta; full release imminent. Sorry for the delay but I just couldn't resist finishing up the property editing. All that's left is running through everything to check for bugs.
Last edited by fafalone; Jan 31st, 2018 at 07:36 AM.
Reason: Beta test finished
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
ucShellBrowse Version 2 has been released.
New Key Features
-Explorer-style Details Pane: It pulls the same list of 'preview properties' to display at the bottom, which vary by file type. For some file types, Explorer lets you edit certain properties-- this project does as well, including popping up date and combo controls. The number of properties that can fit are adjusted based on size. Rows can add with vertical height but it's not sizable at runtime yet (UPDATE: Now is in latest version). As a finishing touch, the "edit invitation" cue banner for blank but editable fields is also included (e.g. "Add tag").
-Dynamic Drag Drop: As you drag over items in the list, folders and zip files are highlighted as you drag over them, and can be dropped on directly. This can be done fully internally as well.
-Directory Updates: The control monitors the current directory for files added, deleted, or updated, and then updates the ListView.
-Sizable Preview Pane: Per request, this is now sizable. Right click the frame caption to select 'Lock width' to determine which control is changed on horizontal resize. (UPDATE: Draggable size bar now present in latest version; Lock width disables it)
-A number of minor features have also been added, as well as a host of bug fixes. See the full changelog below (or in ucShellBrowse.ctl) for details.
A couple more shots of the new detail panes editing ability, popup controls like Explorer:
Here's the full changelog:
Code:
'------------------------------CHANGELOG------------------------------
'v2
'-The Details Pane is now available. It displays what Explorer would. Editing
' values is supported, now for all types (string, number, datetime, list) except
' boolean, which does not appear to be used (if you find where it is, let me know)
'-Added active drag/drop: folders (and zip files) are highlighted as items are
' dragged over them, and can be dropped on directly
'-Active drag/drop allows internal drag/drop as well
'-Added option to disable drag, drop, or both
'-Added option to browse inside zip/cab files (on by default)
'-Current folder is monitored for changes (new item, deletion, update). On by default
'-A splitter bar was impractically complex, but you can now have either the ListView
' or the Preview frame size horizontally-- right click the "Preview" text in the frame
' to set the 'Lock width' option
'-If the control box is on (Back,Up,View) and the width gets so small the directory
' dropdown would disappear, the control box is automatically switched off, then restored
' when the width becomes wide enough again
'-Added option LockNavigation that prevents the user from changing directories. The path
' can still be changed in code with .BrowserPath.
'(Bug fix) Switching from thumbnail view to other views resulted in loss of icons
' and/or detail column text
'(Bug fix) Command box buttons were cut off in different DPI
'(Bug fix) Combo overlapped top of ListView with different DPI
'(Bug fix) Preview pane and ListView height for different DPI
'(Bug fix) View button icon was different in Win10; now just stored internally
'(Bug fix) Navigation couldn't handle certain functionality in the Fonts folder
'(Bug fix) Crash occured after mouseover of shell context menu seperators with id -1
'(Bug fix) Clicks/double clicks on statusbar were interpreted as clicks on the ListView,
' click events changed to verify origin hWnd now
'(Bug fix) At certain control widths a background image holder control was mistakenly visible
'(Bug fix) If multiselect was enabled and your selection drag finished outside an item, item 0
' was set as the focused item (main selection) even if it wasn't selected. If that
' happens now, the first item in the multiselect group (or the real selected item when
' it's the only selected item) is reported as the single selection result
'(Bug fix) If you clicked on a control box button (Back,Up,View) then clicked on the ListView again,
' keystrokes were sent to the buttons instead of the ListView
'==============================
I checked it on high DPI (simulated on a Win8 VM with scale 150%) and everything seems to render and size correctly, which was a little surprising for the details pane since there's loads of manual pixel count calculations... so if there's an issue let me know (and if you want to play with it yourself remember the current scale factors are stored in m_ScaleX/m_ScaleY).
Last edited by fafalone; Apr 14th, 2018 at 05:53 AM.
Reason: Noted that limitations listed are now available in latest version
Version 3 of ucShellBrowse includes a few new features and some critical bug fixes. There's now standard resizing (which can be toggled on/off) between the ListView and the optional Preview/Detail panes. Also, there was a ControlType option listed, but no other modes were implemented. Now they are, and a 'Drives Only' mode has been added; this finalizes being a complete replacement for the VB (Drive|Dir|File)ListBox controls.
It is entering the final testing phase, and posting it makes sense since I'm particularly concerned about DPI on different peoples systems, as there's a number of changes to sizing routines revolving around finally just making the Preview Pane and Details Pane be resizable via a traditional drag bar between them and the ListView. Please report any bugs relating to that or anything else.
Full Change Log:
Code:
'v3
'-Alternate modes for ControlType are now available; control can be Directory Only,
' Drives Only, or Files Only, showing only the combo or ListView, in addition to the
' normal mode of dir+files with both controls.
'-Detail Pane can now be sized with a bar; this also includes correctly scaling
' the icons. The height is 70 by default.
'-The Preview Pane now also uses a resize bar.
'-The Lock Width|Height menus for the panes are still present, and now serve to remove
' the sizing bars. Both sizing bars are active by default.
'-Panes are now redrawn automatically when resized
'-Property columns on the Details Pane will now be widened if there's room.
'-Automatically make a single column match the listview width on startup
'-(Bug fix) After dropping on a folder or zip file, the hilite didn't clear when
' another item was clicked or it was deselected
'-(Bug fix) Dropping on libraries wasn't working; now works for both background and
' dynamic dragdrop
'-(Bug fix) When on the Desktop, any file created/deleted anywhere was added/removed
' from the list
'-(Bug fix) The column right-click menu default properties (name,size,etc) were hard
' coded instead of using the language of the system; now only the 'More..'
' item remains non-localized.
UPDATE FIX RELEASED
Both this version and the previous version of ucShellBrowse contain the code (ppcp.IsPropertyWritable(VarPtr(.pkey)) <> S_OK), but the current release version of oleexp.tlb has this as a Sub (and it cannot work that way). I don't understand why no one seems to have encountered this error before this beta.
It also fixes the two similar typelib-version based errors Steve pointed out below. Apologies for forgetting the version difference.
UPDATE 2
I've finalized oleexp v4.4, please upgrade in order to use the latest version of ucShellBrowse.
(Version 3 has been officially released, so the beta version has been removed. Thanks everyone who tried it out early!)
Last edited by fafalone; Mar 22nd, 2018 at 10:04 PM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Sorry about that, the first two I forgot to define in module; the next version of oleexp.tlb has them defined in the typelib.
.IsPropertyWritable on the other hand, I thought was similar but has me thoroughly confused. That line has not changed since the previous version, and it's a show-stopping error, but it's not come up before? The details pane is on in V2 by default and as soon as you click a file that error pops up. Only thing I can think of is no one ran the V2r1 Demo project and never turned it on in their projects. Was this the case for you (assuming you used the prev. version at all)?
Going to have to investigate this further... in the mean time, I'm putting a copy of the latest dev build of oleexp.tlb in the zip; there's no changes to existing interfaces besides the .IsPropertyWritable, so it's safe to replace. See below.
Update
There's no getting around needing that to be a function; I've finalized and released oleexp.tlb 4.4, so that's going to have to be updated to use v3 (and apparently v2).
Last edited by fafalone; Mar 16th, 2018 at 06:06 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Version 3 Officially Released!
Everything appears to be ok on high DPI systems from my testing, and that was the final delay. A number of features have been added since the initial beta, so you'll want to grab the new release even if you downloaded that.
The biggest changes are a Bookmarks button, new control modes (the ones that were listed but weren't implemented, along with a new 'Drives Only' mode), draggable sizer bars for the preview and details panes, and a checkboxes option. Beyond that there's lots of little features, improvements, and bug fixes-- definitely worth upgrading.
Here's the full list of changes:
Code:
'v3
'NOTE: If you had moved the functions from mSBSubclass, be advised this version adds
' one more wndproc, DthWndProc.
'-Added an optional Bookmarks button in the control box (hidden by default). Note that
' the entries are stored in the system registry, under ucShellBrowse (UserControl.Name)
' in the VB programs section. See the variable in the section just below this readme to
' set the max number of entries (initial default = 48)
'-Alternate modes for ControlType are now available; control can be Directory Only,
' Drives Only, or Files Only, showing only the combo or ListView, in addition to the
' normal mode of dir+files with both controls.
'-Added option to select files by using checkboxes (off by default).
'-Detail Pane can now be sized with a bar; this also includes correctly scaling
' the icons. The height is 70 by default.
'-The Preview Pane now also uses a resize bar.
'-The Lock Width|Height menus for the panes are still present, and now serve to remove
' the sizing bars. Both sizing bars are active by default.
'-Panes are now redrawn automatically when resized
'-Property columns on the Details Pane will now be widened if there's room.
'-Automatically make a single column match the listview width on startup
'-Added SelectedFile/SelectedFiles property get/let to retrieve just the filename, and
' the let allows changing the selected item(s) to the given name(s)
' NOTE: Since Property Lets cannot accept an array directly, SelectedFiles uses a
' Variant to hold the (string) array (applies to the Get as well since they must
' use the same type).
'-Added some additional UserControl event forwards (mouse actions, these only apply to
' the small background areas of the UC, not the controls on it)
'-Added ItemAdded/ItemRemoved event for changes in the currently displayed folder (does
' not fire during the location changing)
'-Added FileDetailsWrite event for when file metadata is written from the Details Pane
'-Added StatusMessage event that fires when the control updates its status message
'-Added Files() and Folders() function to get a list of *all* files/folders instead of
' just the selected ones, also FilesFullParsing/FoldersFullParsing to supply a list of
' full paths/filenames with the absolute names (SIGDN_DESKTOPABSOLUTEPARSING). Whether
' ZIP files are counted as files or folders is controlled by whether the BrowseZip option
' is enabled or not-- if it's treated as a folder it's counted as one.
'-Added additional sizing restrictions to prevent elements from being sized to 0
'-(Bug fix) The file name caption in the Details Pane used a standard label, so could
' not display Unicode. It has been replaced with an API-created label to allow
' tbat. Additionally, the label uses the system default caption font.
'-(Bug fix) After dropping on a folder or zip file, the hilite didn't clear when
' another item was clicked or it was deselected
'-(Bug fix) Dropping on libraries wasn't working; now works for both background and
' dynamic dragdrop
'-(Bug fix) When on the Desktop, any file created/deleted anywhere was added/removed
' from the list
'-(Bug fix) The column right-click menu default properties (name,size,etc) were hard
' coded instead of using the language of the system; now only the 'More..'
' item remains non-localized.
'-(Bug fix) The Preview Pane may have overlapped the Details Pane when the height was
' below a certain point.
'-(Bug fix) When changing control properties in the IDE, the PreviewPane property would
' get stuck in the True position.
'-(Bug fix) When changing the ListControlBox property, the path combobox didn't adjust
' to not overlap it. It now does in both design time and run time.
And to look ahead, it's not in this version since it requires an upgrade to oleexp (or would require a whole other typelib), and I just released one, but...
Coming soon to a ucShellBrowse near you:
Last edited by fafalone; Mar 23rd, 2018 at 02:44 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Fafalone,
Your instructions for using the .ctl version says "your project must contain mSBSubclass.bas (from the main folder of the project)" and I don't find that file in either the demo project or in the files for v4.4 of oleexp. Am I missing something?
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
mSBSubclass was in the root folder along with the .ctl.... BUT, there's now a huge update and it's no longer required with the new version.
Version 4 Has Been Released!
This is the largest update since the project began, with 23 new or enhanced features and 18 bug fixes, and the control now uses Paul Caton and LaVolpe's self-subclass/self-callback thunks (modified to handle the large proc count) so the subclassing .bas is no longer needed. There's an optional graphics/manifest resource file included: It enables replacing the menu images with higher quality transparent icons (this is automatic, no additional code needed and if the .res isn't present the control falls back to the originals); and also a Common Controls 6 manifest, which you can delete if you've already got one but want the icons. An additional demo project is included that shows minimalist use of the control, similar to the original folder/file list VB controls. Most important for that is the new HideColumnHeader option, which lets you keep the control in Details view so the scrolling is vertical instead of horizontal like the other small icon views, without the big ugly header saying Name.
IMPORTANT: This version requires an update to oleexp.tlb as well, to version 4.42, released concurrently with this project (April 13th).
Here's a pic of the new footer, as well as Explorer-style infotips that display different properties as a tooltip, the properties chosen based on filetype (the ones from PKEY_PropList_InfoTip). Also shows the full name if it's wrapped ('...').
And also, various new features (and a new demo) to make minimalist usage better:
Your control can be configured to be like the first pic, the second, and everything in between.
Full list of changes:
Code:
'v4
'(Code/Control) mSBSubclass is no longer needed. All subclassing/callbacks are now
' done with Paul Caton/LaVolpe's Self-Subclass/Callback code.
' Special thanks to LaVolpe and Victor Bravo VI for helping me on that.
'
'-A footer control can now be added to the view. Be advised this is done
' using undocumented interfaces and messages; it works as of the latest
' version of Windows 10 at the time of this release, and back to Vista.
'
' The calls are FooterCreate, FooterAddButton (to add another one after the initial
' set), FooterClearButtons (not possible to remove a single one), and FooterRemove.
' It's recommended to use the lParam to store a unique identifier, but both that and
' the button index are passed in the FooterButtonClick event that's raised on click.
' The number of buttons is limited only by practical space.
'
' You have two options for footer icons:
' 1) Create an API ImageList (or IImageList then ObjPtr() to it), and pass an array of
' Long with the index for each item as the tButtonIcons argument.
' 2) If you have a resource file, add the .ico files to it as a 'CUSTOM' resource, with
' a name in quotations, e.g. "ICO_FOOTER1". The icons can be 32bit alpha icons or any
' other ICO file type. The control will then create the ImageList itsself... pass 0&
' as the value of hImageList, then pass a String array with the resource name for each
' item as the argument for tButtonIcons.
' See the Demo project for code showing both approaches.
'
'-Hovering over an item now shows an InfoTip like Explorer; a multiline tooltip with the
' full file name (only if the label is truncated), then several properties depending on
' file type and whether the property is blank or not.
'
'-The columns are more like Explorer several ways; in special folders, like Computer,
' Fonts, and Network, only the limited cols that are shown in Explorer are listed (and are
' added to the right-click column menu if there's only a few of them). Columns added
' recently are now listed (if available in the current folder).
'
'-There's a resource file in the ucShellBrowse folder, resImages.res, that you can add
' to the control or to a project with the CTL (the Demo has it now) to make the icons
' on the View menu transparent, and add a few more icons. There was no way to do this
' without an extra file. If you do not add the resource file, the old icons with the
' slightly off-color background are still present and are loaded instead. You can also
' use this resource file to add icons for the footer (see above).
'
'-Additional options have been added to give you more control over the runtime:
' EnablePreview - Show/hide Preview Pane from the View menu (keeps it locked to design
' time setting)
' EnableDetails - Same for Details Pane
' EnableViewMenu - Toggles whether the View menu pops up for LV background right-click
' LockView - Keeps the design-time view (Details, Large Icons, etc) by hiding menu options
' HideColumnHeader - Show/hide the column header in Details view.
' MinDroppedWidth - Set a minimum width for the ComboBox; useful for simple modes.
'-Properties to get the major control hWnds also added: hWndCombo and hWndListView
'
'-Previews are now centered in the frame instead of in the top left
'
'-You can now manually set an image in the Preview Pane, there's subs SetPreviewPicture
' and then StdPic, hBitmap, and hIcon.
'
'-The width of the preview pane, and height of the details pane, now have a get/let
'
'-Tile View now shows 3 details instead of 2; type, size, and date modified
' property. The preview height/detail width are Get only; adjust the control itself
' to change the other dimension.
'
'-The column menu popup (when right-clicking the column header), recently used columns
' that have been removed are now listed.
'
'-The Status Bar now shows the number of files that are selected.
'
'-On the Details Pane, properties can't be edited on a read-only file even if the prop is
' normally able to be edited-- in this situation empty properties are no longer displayed.
'
'-The items listed in the columns checklist included many that were unsupported in Explorer;
' they're now limited to supported columns (i.e. the same set you see in Explorer).
'
'-For the 'More...' columns popup frame, it now increases in height if the main ListView
' height is large enough. Also, it's no longer clipped by the UserControl being shrunk while
' it's visible, it will be on top of the host form (and will be clipped by total form height).
'
'-Added shortcut to de-select all items when Escape is pressed (and ListView has focus).
'-Alt+Enter on the ListView will now display properties of the selected items (or the current
' folder if nothing is selected).
'
'-Shift+Delete has been added as a shortcut to permanently delete files (no Recycle Bin).
'
'-Added event for debug message; logging to file will not be added to this control, so
' this allows for it to be implemented by the host project.
'
'-Back button is now disabled when there's no further previous locations.
'
'-The 'Up' button is now disabled when the root is reached (Desktop, or Computer if
' using the 'ComputerAsRoot' option).
'
'-Extended columns that are dates or numbers are now sorted as such (instead of plain text),
' however the number sorting is currently imperfect as it takes the Val() of the text, in
' the future this will be changed to compare the raw numbers (not easy to set up).
'
'-Added StatusSinglePanel option to only show the first panel of the StatusBar; mainly for
' when the control width is small.
'
'(Bug fix) If the Details Pane was turned on via code at runtime, it came up blank until
' something was clicked. Now, it renders the background view (folder icon+count)
'
'(Bug fix) In Tile View mode, if a new file is created and added (i.e. not part of the
' list when tile view was activated), including switching dirs, the extra lines
' were not displayed.
'
'(Bug fix) When new items are added via shell notify, details (column subitems) were not
' loaded, despite the fact the normal property enumerator function was called. This
' was fixed, oddly enough, by simply calling it twice.
'
'(Bug fix) For some reason, if a button in the control box had focus when a new folder was
' created, all keys went to the name label... *except* enter... so you'd type a new
' name, hit enter, then the View menu would pop up, or the control would navigate to
' Up or Back. The new name was still applied when the label edit ended.
'
'(Bug fix) Sort Ascending/Sort Descending menu options on the view menu had not yet been
' implemented (though clicking the column to change sort direction was).
'
'(Bug fix) The initial ViewMode property was stuck on 1 - Details due to that mode entirely
' breaking if column initialization didn't run while it was on. I don't understand
' why the behavior is different versus loading a new directory while in non-details
' mode, and haven't been able to identify a direct fix, so it was locked. But this
' version adds an indirect workaround-- temporarily switching to Details, running the
' default column init, then switching back before items are added; allowing it to
' work as expected. All View Modes, including Tile and Thumbnail, can now be chosen
' as the initial view, without breaking the display of any other mode switched into
' during runtime.
'
'(Bug fix) When 'Keep same columns' option was enabled, only columns present when enabled would
' be remembered, forgetting any columns added to the current view afterwards. Now, the
' current column set is retained as displayed at the time of the switch.
'
'(Bug fix) When adding additional columns from the checklist, if more than one was selected, only
' one of the details would be filled in until the folder was refreshed or changed.
'
'(Bug fix) On the Details Pane, the mouse cursor no longer changes when over properties that can't
' be modified. The text box was still read-only, but this clears up the visual confusion.
'
'(Bug fix) 'Computer As Root' mode still loaded the Desktop when you clicked Computer in the combo.
'
'(Bug fix) Sorting by date accessed or date created wasn't working.
'
'(Bug fix) Sorting by extended columns required 2 clicks because the column index lagged one behind.
'
'(Bug fix) File name colors (blue for compressed, green for encrypted) stopped working sometime
' between version 1 and this one.
'
'(Bug fix) Renaming files in response to shell notifications deleted and re-added, resulting in the
' property fields turning blank. Now there's a proper rename that just updates the item, so
' the properties stay filled.
'
'(Bug fix) The control uses a few common types, like RECT, POINT, and SIZE, that are defined in
' (code) oleexp.tlb. If these were publicly defined in your project, the priority would be higher
' and you'd get Type Mismatch errors. The generic types have been explicitly changed to
' 'As oleexp.RECT' etc. A private type wouldn't have worked without more trouble; can't
' pass them to tlb interfaces. Less common types and APIs were also preemptively changed
' to explicit calls just to prevent potential conflicts; e.g. API is different or takes
' an oleexp type; these would error if conflicted with a Public Declare.
'
'(Bug fix) Setting the mode to Files Only then changing it back to Dir+Files caused ListControlBox
' to get switched off and stick a little.
'
'(Bug fix) In Dir Only or Drives Only mode, there was an artifact from the Status Bar if it was enabled,
' and since that's the default, it's now hidden in those modes regardless of ShowStatusBar.
'
'(Bug fix) In Files Only mode, the top of the ListView was not the top of the control, resulting in the
' status bar being overlapped if it was visible, and the blank space at the top of the control.
Last edited by fafalone; Mar 26th, 2021 at 05:17 AM.
Reason: fixed image
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
The new version requires an update to oleexp (to version 4.42, just released for this) because of the interface needed for the footer bar. It was in another tlb but I merged it into oleexp so as to not add an additional tlb depend. I noted it in the first post but I'll add it to the release post as well, sorry for not making that more clear.
But I'm not sure why MAX_PATH would be undefined; that's been included in oleexp for a long time now (since 2015's v3.2), and the line in question has been present and unchanged since the very first release of ucShellBrowse (along with many other instances of it, always relying on the tlb). If it's still an issue after 4.42 let me know; I'll try to figure it out... I did test compile on my native Win7 and the Win8 VM that's a clean test platform with just the files posted, without any such issue.
Last edited by fafalone; Apr 14th, 2018 at 01:42 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
ucShellBrowse v4.1 has been released
This is a minor update that has important fixes for Unicode support. Also, the dependency on mscomctl.ocx (Microsoft Windows Common Controls) has been removed, as the 2 controls that were using it are also done entirely in API now. The lag surrounding selecting/deselecting large numbers of items has also been addressed.
Code:
'v4 Rev 1
'
'(Code/Control) The reference to Windows Common Controls 6.0 (MSCOMCTL.OCX) has been
' removed. They were used for the StatusBar and Column Selection list;
' these are now created entirely with API. This leaves oleexp as the
' only outside dependency.
'
'-Removed delays when selecting/deselecting large numbers of items. Each change was
' being rendered to the Details Pane, which could cause several seconds of visible
' refreshing. Now, when an item changes, a timer is set, so that any more items
' selected in the next few milliseconds is included in a single update. See the
' nSelUpdateMillisecs constant in the section below these comments to adjust.
'
'-When a new folder is loaded, focus is now automatically set to the files list.
'
'-Added option to hide labels (file names). This doesn't impact any operations, just
' display. Useful for e.g. just showing thumbnails without filenames in the way.
'
'(Bug fix) Rename-in-place did not support renaming files with extended Unicode
' characters; after also adding support to valid name checking from paste
' and several more issues, it's now fully supported-- you can rename and
' type, paste, delete, etc, with the full set of characters.
'
'(Bug fix) When Details Pane fields were saved, Unicode characters were replaced with
' question marks. This effects v4 but not v3/v2.
'
'(Bug fix) Sometimes when files are pasted, if they have a custom icon (like a .exe
' or .ico), only the generic file icon was shown.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Version 4.2 Released
Nobody noticed the rather severe bug that the directory dropdown was not changing??? I'm so sorry I didn't notice it earlier; put in a last minute change to try to speed usage by setting focus after loading a new directory, and for some inexplicable reason VB insists on waiting for all code to run, even with doevents, and then changing it, which for some reason the focus change prevents.
(If you want to just fix this yourself in the current version, at the end of LVLoadFolder, comment out the two lines SetFocus UserControl.hwnd and SetFocus hLVS)
But anyway, there's a couple other new features that were ready too. Browsing is now able to handle the Recycle Bin and Recent Places (the latter needing special handling). Details Pane shows icon/info correctly in ZIP/CAB now.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Version 5.0 Released
This is a major update with tons of new features.
Some of the highlights:
Custom folders: You can specify a list of files from anywhere on the system and display them together in a single folder.
Graphics options: You can now add a background image (in a position or tiled), change the background color, change the foreground (font) color, and change the font.
Groups can now be collapsed and subsetted.
High DPI scaling is now supported.
The release zip contains 4 different demo projects:
\Demo - The standard project demo, with the color changes shown above (you can change them back in the regular design mode on Form1)
\Demo2 - Minimalist options that mimic the original VB Directory and Files control.
\Demo3 - The two-control setup pictured in post #2 where you use two different ucShellBrowse controls for an alternative layout.
\DemoEx - Full-sized browser setup working with ucShellTree. NOTE: Requires ucShellTree which is downloaded separately - Get it here, then put \ucShellTree next to \ucShellBrowse
Custom font, tiled background, and no border.
Ratings stars, subsetted groups, custom foreground and background colors
Automatically populated Special Folders submenu for the Bookmarks menu.
Version 5.0 Changelog
Code:
'v5 (Released 16 Nov 2018)
'-Can display a custom set of files from anywhere on the system. Call the method
' CreateCustomFolder with a list of full paths and other options. Shell context
' menus won't work with multiple files (will execute on focused item), but some
' custom handlers have been added, and it works normally for a single file.
' nIcon can be left as 0 for a standard folder icon, -1 for a search folder icon,
' or any icon index in the system imagelist.
'
'-Control now fully supports high DPI scaling. This requires the dpiAware=True
' value in the manifest. The default manifest, resImages.res, includes that
' setting, but if you want to disable it, resImages-NoDpiAware.res is identical
' except for that setting, and can be readily swapped into this project instead.
'
'-If the 'Rating' column is loaded in Details View, either as a default column
' or selected from the column list, the rating will now appear as a series of
' stars that you can manipulate just like Explorer. Fully supports groups.
' NOTE: This requires the PNG_RT* images in the resource file.
'
'-Additional checks were added before renaming files. This catches errors not
' caught by watching keys, like reserved filenames, invalid filenames made of
' valid characters, and overall path being too long.
'
'-Some virtual folders, like Network Connections for example, have a custom set of
' columns that are not part of the regular property system, so previously could
' not be loaded. They're now viewable through some custom handling.
' This routine also exposes custom columns in virtual folders like 'Network' where
' prior versions could only show the columns that were standard.
'
'-Added a 'Special folders' submenu on the Bookmarks menu containing a number of
' common special folders. You can adjust/add/remove the ones you want in the
' GenerateSpecialFolderMenu/GetSpecialFolderMenuItem methods. Virtual folders are
' supported.
'
'-Added the Bookmarks menu to the View Menu when showed from a folder background
' right click. This is still controlled by the Bookmark Button property, so the
' submenu is only added if the button is (or would be) visible. This allows the use
' of bookmarks without the List Control Box or in Files Only Mode.
'
'-The font for the ListView/Combo/Status can now be changed. (Borrowed from Krool's
' ListView. Thanks!)
'
'-Added CustomColor event, which allows you to set a custom font color and background
' color on an individual item and subitem basis. The file index and file name are sent,
' along with the column index and the system name of the property it's displaying --
' e.g. if the 1st column after the name is size, SubItemIndex=1 and SubItemProp="System.Size"
'
'-Better support for drag-out of virtual objects that can have shortcuts created.
'
'-Added property to control whether sorting is allowed or not.
'
'-Added option to disable Wow64 file system redirection.
'
'-Added ExplorerStyle option to toggle visual styles (defaults to Explorer Theme)
'
'-Added SnapToGrid option. This only applies in icon / small icon / tile views.
'
'-Added HeaderDragDrop option.
'
'-Added TrackSelect option (the selected item follows the mouse pointer).
'
'-Added BorderStyle select with None, Standard, Thick, and Thicker options for the LV.
'
'-Added property SelectedColumn (for runtime only, won't appear in Properties design box).
'
'-Added additional methods to get file info: FileCount, FolderCount, FilePathFromPos and
' FileItemFromPos (which returns a files IShellItem).
'
'-You can now set a background image for the file browser ListView. There are 3 sources
' supported: A normal VB picture you can set in the UserControl Properties box, a Sub
' to directly pass an HBITMAP, and a Sub to pass a URL.
' PictureAlignment and PictureWatermark options are present and apply to all three image
' sources. Special thanks to Krool, the Picture option was adapted from his ListView
'
'-Added BackColor property, added ForeColor property for the main item text, and also
' ForeColorSubitem for the subitems when using Details View (Report Mode).
'
'-Added experimental Extended Tiles view mode. The layout is similar to Explorer's Content
' view, but I don't know how to use columns other than the ones that Detail View had.
' This option is disabled by default. If you want to try it, go down to the User Consts section
' immediately after these comments and change bHideContentViewMenuItem to True.
'
'-Added 'Enabled' option to enable/disable everything on the control.
'
'-Groups can now be subsetted: Only a certain number of items are shown with a link at the
' bottom to show more. Set the count with GroupSubsetCount and the text of the link with
' GroupSubsetLinkText. It defaults to no subsetting and there's default text of "Show more items"
'
'-Groups are now collapsible. Added GroupStartCollapsed option to set them collapsed by default.
'
'-Misc. adjustments to the Details Pane layout to support different DPI scaling and make better
' use of the space to avoid unneeded truncations.
'
'-When you click on a text field you can edit in the Details Pane, the textbox background will now
' turn white like it does in Explorer, and back to transparent when out of focus. This is to make
' it more clear that an edit is in progress.
'
'-Checkboxes can now be toggled during runtime, and there's a FileCheck event when checked/unchecked.
' Also, added FilesChecked() method to get list of checked items, and FileGetCheck and FileSetCheck to
' toggle checkmarks by name.
'
'-(Bug fix) View Menu and Bookmarks Menu did not work on Windows 10 due to missing FOLDERID_ values.
'
'-(Bug fix) Some internal file data was not being updated after a rename, which
' caused failures in the shell context menu commands.
'
'-(Bug fix) There were a number of circumstances where actions on virtual objects,
' usually in virtual folders, failed. Most of these have been corrected
' thanks to the methods developed for the virtual folder custom colsets.
'
'-(Bug fix) 'New folder' and 'Paste' commands are now disabled in the menu when in
' folders where they will not work.
'
'-(Bug fix) Corrected some spacing issues in the Details Pane when DPI scaling is on.
'
'-(Bug fix) In Files Only mode, the ListControlBox would slight reappear if the control
' was resized to a small width then resized back. This was related to the
' feature to auto-hide it; the control didn't check the mode so always restored.
'
'-(Bug fix) If the UserControl was not placed in the top left of the form, the column
' select popup would appear in the wrong place. The reason was that the only
' way I could get it to appear on top of everything was to set its parent
' as UserControl.ContainerHwnd; no other method including SWP HWND_TOP worked.
' So it was being placed relative to the form, instead of to the UC. Fixed.
'
'-(Bug fix) Some virtual locations, like Network Connections, were not showing the help text
' (for the status bar) with the right-click menu; these folders seem to not support
' the IContextMenu2 interface that was used. But the text only needs the base
' IContextMenu, so that was made into a module-level var as well used in 2's place.
'
'-(Bug fix) When Group Mode was active and the folder changed, sometimes the group item count
' was not updated or displayed the wrong number.
Item position and filename, the column number, and the system property name-- e.g. System.Size. Set rgbFore and/or rgbBack as desired, leave unchanged to stay with the current defaults.
FileCheck(Index, sFile, fCheck)
When Checkboxes are enabled and there's a change. fCheck = 0 for unchecked, fCheck = 1 for checked. File position and full path are sent.
New Methods
CreateCustomFolder(Title, Files(), Icon)
View files from around the system together. Specify full paths for file list. If Icon is -1, the Saved Search system folder icon is used. If 0, a plain folder icon. If >0, specifies system imagelist index.
FileCount
Returns the number of non-folders.
FolderCount
Returns the number of folders.
FilePathFromPos
Returns the full path of the zero-based position of entries.
FileItemFromPos
Same, but returns an IShellItem.
PictureSetByHBITMAP
Specify an HBITMAP instead of picking the Picture property normally.
PictureSetByURL
Same, by URL.
FilesChecked()
Returns a list of the full paths of checked items.
This new version brings a number of new and improved features and some important bug fixes.
Highlights:
Percent full bar graph in Computer (technically, any folder/items with the System.PercentFull propertykey will now render like this, but I've never seen it used elsewhere)
Option for graphical Back button
All icons now support high DPI
If you change columns displayed, they're remembered if you go back to the folder
-The demo project lineup is the same as the 5.0 release, details in the post immediately above this one. Small change in that cLog is included and DemoEx logs debug output of compiled exe.
-The standard resImages resource file is significantly smaller after removing unused icons and 128/256 pixel icon sizes used only in 16x16 spots.
Here's the full list of changes:
Code:
'-For high-DPI scaling, the control will now attempt to load the Control Box icons
' from the resource file, which contains icons with multiple resolutions for scale.
'
'-The menu icons, when available in the resource file, now also scale to DPI. The
' backup icons from picture boxes remain available for projects without the .res
'--Additionally, numerous positioning adjustments were made to make item positions
' consistent with the standard appearance when running in high DPI.
'
'-In the Computer folder, the Percent Full (Space Used) is now displayed as a
' progress bar like in Explorer instead of just the number. Details View, Tile View,
' and Contents View are supported.
'
'-In Details View, the column set will be remembered when the folder is refreshed
' or navigated to again after leaving.
'
'-Added option to use an Explorer-style round back button on the left of the combo,
' or a new option to hide the back button entirely (Backbutton Property).
'
'-Added FileGetProperty function to retrieve properties.
'
'-Added HeaderNoSizing option to prevent header resize.
'
'-Added ControlBackColor option.
'
'-When Checkbox mode is enabled, a checkbox now appears in the 'Name' column
' header that allows you to check/uncheck all items.
'
'-Changes to the Control Box are applied during design-time as well.
'
'-Added SortItems event with column, direction, and property sorted by.
'
'-Added HighlightColumn[ByProperty] methods to change the background of a given column;
' the above SortItems event was added with highlighting the sort column in mind, but
' it can be used in any other way as well. NOTE: This uses undocumented interfaces and
' calls; it was working on Win7-10 as of release but be wary of future issues.
'
'-The main Libraries folder is now expanded by default in the directory dropdown.
'
'-Added EnableShellMenu option to control whether the right-click Explorer context menu shows.
'
'-The ListView border style can now be immediately changed during both design-time and runtime.
'
'-Added FoldersOnly option that controls whether files are listed in the main view area, as
' opposed to the dropdown (this option does not effect the dropdown).
'
'-In the Details Pane, fields that can be edited are now highlighted with a border during
' mouseover (and while editing).
'
'-(Design mode) Control Type changes are now applied in design time without close/reopen.
' But it is not possible to change the control type at runtime.
'
'-(Bug fix) If the Bookmarks Button was enabled, but the View Button wasn't, the
' Bookmark Button wasn't positioned right and would not show up.
'
'-(Bug fix) The Bookmarks Menu icons were not DPI scaled.
'
'-(Bug fix) The stars for the Rating column were mistakenly drawn after the column
' was removed in a directory change.
'
'-(Bug fix) The status message containing the selection count, while in Checkbox
' mode, was only updated after a normal select action instead of the
' checkbox toggle.
'
'-(Bug fix) The AllowSorting option couldn't be turned off during runtime.
'
'-(Bug fix) When you double-click a folder, the '1 file selected' didn't clear after
' the new location was opened, therefore incorrectly indicating that a file
' was still selected.
'
'-(Bug fix) Checkboxes were being handled as if they were the selection; this was
' causing issues with previews, details, and some other areas. 'Selected'
' now always refers to just the highlight, and 'Checked' is an entirely
' different thing.
'
'-(Bug fix) Some registered preview handlers fail to load. This situation is often
' fixed by trying different arguments in CoCreateInstance; all 3 ways are
' now attempted before giving up.
Special thanks to Charles P.V. for his ucListView control, from which I adapted the subitem progress control.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Fafalone,
I am having trouble with your demos. In the first one there is a reference to:
ResFile32="..\resImagesNoMan.RES"
but there is no such file in the package.
Also, the projects in Demo2 and Demo3 do not have any references to resource files and do not have manifests but they do have a reference to v5 of the common controls so they have no visual styles. Was that intentional?
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Damn I specifically checked to make sure the demos were referencing the right resource files... no idea how that changed, I went through every one to check it referenced resImagesStd. You can swap it for the .res that is included; that reference is an alternate version without a manifest (see here in post 2), or redownload it after I update it in a second. Sorry about that.
For 2 and 3; yeah I had left out a manifest and resource on purpose, to demonstrate the simplest usage of the control. The reference (which is actually to 6) should have been removed; nothing from either ocx is used in the control or any demo.
Edit (23 Dec 2018): Project Updated. Fixed the reference in Demo, removed unneeded mscomctllib reference in Demo2 and Demo3. I had added a FollowLinks option to open folder links inside the browser, so updated the main control while I was at it.
Edit (11 Jan 2019): Project updated to Version 5.12. There was previously no 'Files Only' mode where folders could be hidden from the main file view. This is a fairly egregious oversight that warranted an immediate update instead of waiting for the next full version increment. There's also a few other improvements:
-Custom filter for when ItemFilter isn't enough; raises the FilterFile event.
-Bug fix for Drives Only mode where changing to a non-root path loaded the folders.
-Bug fix for the PercentFull progress bars; they only appeared in Tile Mode if you switched to it while in the Computer folder; also they're now blue instead of green:
The ProgressBars for the Computer folder are drawn using the Theme API, rather than actually creating a progress control, and unlike an actual progress control, the Theme API for progress bars allows the blue that you see in Explorer.
Last edited by fafalone; Jan 11th, 2019 at 12:38 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Version 5.2 Released
This version adds new combo box styles - both dropdown list (all modes where its visible) and simple combo (for dir only/drive only). In addition, it can be enabled/disabled for typing, and when typed into can be used for navigation. The ListView Header has some improvements too, the FilterBar can now be shown, and has built-in filtering and optional manual override, and can now be shown in all views for that filtering or just because. The Column Select list is no longer stuck; you can now resize it and drag it around.
Then for those odd folks wanting to use this without a CC6 manifest, you can now switch views during runtime and thumbnail mode actually works semi-well now.
Finally there's some positioning adjustments and a few bug fixes, included the unloading issue that was up in Known Issues for a while.
Here's the full changelog:
Code:
'-Added ComboType option to make the directory dropdown appear as the DropdownList
' style instead or, if in DrivesOnly or DirOnly mode, a simple combobox.
'
'-Added ComboCanEdit option, which allows (except in ComboType=DropdownList) you to
' edit the combo text. Double-clicking will set it to the full path of the current
' folder, and pressing enter will navigate to the given location- specify a full path
' or the name of a folder in the currently displayed location.
' This is accompanied by the ValidateTextNav event, if you wanted to set shortcuts
' or otherwise adjust/replace the text entered into the box when enter is pressed.
'
'-Added FilterBar option to show filter bars in the column headers. The filter is
' matched by default as follows: If a wildcard (*) is present, the comparison uses
' VB's Like statement; otherwise, it's matched char by char from the left, e.g. ab
' would match abc.txt, but not cabc.txt.
'--FilterCaseSensitive option was also added to control case sensitivity for the filter.
'--Event FilterBarOverride was added to allow for custom handling/more complex filters.
' The filter text, column text, and filename are provided. Set fShow to 1 for a match,
' 0 for no match, and do not set it at all if you are not using this feature.
'--This feature is compatible with Group View: If Group View is not enabled, it creates
' a single group with the matches. If Group View is enabled, it simply removes items
' that don't match from their groups.
'--Also included is the FilterBarApplyManually public sub, so that a filter bar action
' can be executed without even having to enable the filter bar.
'
'-Added HeaderInAllViews option, which if enabled shows column headers in the other
' view modes besides Details. The FilterBar can be used in this scenario.
'
'-The Details list of all properties to show (Column menu->More...) can now be moved
' around and resized.
'
'-Default column width is now pegged to m_ScaleX (DPI zoom).
'-Folder dropdown height is now pegged to m_ScaleY.
'
'-Made various positioning updates to Details Pane.
'
'-Added rudimentry support for thumbnails without Common Controls 6. The images won't
' appear nearly as nice, as semi-transparent pixels stay black, but fully transparent
' pixels use masking to change them to the background color.
'
'-It is now possible to switch view modes at runtime without Common Controls 6. This
' isn't possible by default, so the entire ListView is destroyed and recreated in the
' new view. Details are still supported, but tile view, content view, and group view
' modes are still all unavailable.
'--Unsupported modes are no longer shown on the View Menu, and automatically switched
' to Large Icon view if set during design-time.
'
'-(Bug fix) If the control was on a secondary form, unloading that form did not unload
' the control, and it stayed loaded in the background until the whole program
' ended. Thanks to dz32 and Eduardo- for figuring out the solution.
'
'-(Bug fix) Ratings stars were not rendering if the ListView was scrolled horizontally.
'
'-(Bug fix) The global variable containing the current path was updated in .BrowserPath
' before the location was validated; this could lead to various problems with
' interacting with files in the current view after entering an invalid path.
'
'-(Bug fix) The Details Pane and Preview Pane were still visible if enabled when the
' control type lacked a file view (DirOnly/DrivesOnly).
'
'**NOTE** This control is nearing feature-complete. I expect the next update will be to
' finalize things; massively clean up the code, remove all unused methods, pare
' down debug output and switch off by default...
' SO... If there's any features you'd like to see in this control, or ucShellTree
' which will be finalized at the same time... now would be a great time to drop by
' the thread or e-mail me!
To repeat the note, any ideas for additional functionality, let's hear 'em soon, it's time to set this as feature-complete and clean it up.
Last edited by fafalone; Feb 6th, 2019 at 04:17 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
This is a great control. I am using it.
I know that you plan to improve it. That is why I would like to bring to your attention a number of changes that would be nice to have:
1. In the current version of ucShellBrowse, the user can type or paste anything in the combobox on the top-left where the user navigates through the folders.
That kind of input should be disallowed, because that combobox is not a real address bar. It implements a tree structure somewhat similar to the left panel of Windows Explorer.
It is not similar to the address bar of the Windows Explorer.
So, the fact that the user can type (or paste) things in there (and then press Carriage Return and nothing happens) is confusing.
2. The navigation buttons look very different from Windows Explorer.
Also, in the current version of ucShellBrowse, there is no Forward button: https://i.imgur.com/XVYkBga.jpg
It would be good to have a forward button as well, and also it would be nice for these navigation buttons to look the same as what they look in Windows Explorer.
3. In the current version of ucShellBrowse, the Status bar as a whole (as well as its partitions (I guess it consists of two partitions)) have a very dim (almost invisible) border line: https://i.imgur.com/XmUxCrn.jpg
It would be nice if the Status bar (as a whole) and also the vertical divider line(s) inside it, could be made very visible and conspicuous.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
1) The ComboBox is in fact also an address bar, from version 5.2:
Code:
'-Added ComboCanEdit option, which allows (except in ComboType=DropdownList) you to
' edit the combo text. Double-clicking will set it to the full path of the current
' folder, and pressing enter will navigate to the given location- specify a full path
' or the name of a folder in the currently displayed location.
' This is accompanied by the ValidateTextNav event, if you wanted to set shortcuts
' or otherwise adjust/replace the text entered into the box when enter is pressed.
2) The Back arrow can be drawn with actual Explorer theme; the 'BackButton' property can be used to switch to that one if you prefer; set it to SBBK_ThemeButton.
Will definitely work on a forward button at some point; I keep getting a headache when thinking about all the scenarios to track to not lose place going back and forward while opening new folders in between lol.
3) Not sure what can really be done about that... adding the WS_BORDER style adds a border at the top, but not the bottom. I'm going to add an option to add a border around the whole control; not sure if that's an acceptable solution for this though. The divider line, can't do anything about that short of custom drawing the whole thing.
One possibility might be putting a line control under it; will see if I can make that look decent. Edit: Even setting the statusbar to bottommost, it draws on top of the line. You'd have to put this on your form rather than in the control itself.
Last edited by fafalone; Feb 17th, 2019 at 11:47 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
A number of little problems:
1. There is a problem with de-selecting a file.
I have some code that shows the name of the selected file in a textbox, when I click on a file, the ucShellBrowse1_SelectionChanged event is fired and my code in there shows the file path in the textbox.
But, then I click on the white space between the file thumbnails, and that event does not get fired.
And there isn't any other way to blank out that textbox if the user de-selects a file.
I have tested with any of the following:
Code:
Private Sub ucShellBrowse1_SelectionChanged(arFullPaths() As String, sFocusedItem As String, siFocused As oleexp.IShellItem)
If ucShellBrowse1.SelCount = 0 Then
txtFileSelected.Text = ""
Else
txtFileSelected.Text = ucShellBrowse1.SelectedFile
End If
End Sub
Or:
Code:
Private Sub ucShellBrowse1_SelectionChanged(arFullPaths() As String, sFocusedItem As String, siFocused As oleexp.IShellItem)
If UBound(arFullPaths) - LBound(arFullPaths) + 1 = 0 Then
txtFileSelected.Text = ""
Else
txtFileSelected.Text = arFullPaths(0)
End If
End Sub
And the problem with de-selecting a file happens in both cases.
2. Also, when I was experimenting with this control and did some selecting and de-selecting files several times, suddenly a strange message showed up:
3. Another thing that caught my attention is that that message that showed up for an unknown reason (the above screen print), is not a hard message (unlike a VB6 MsgBox).
I can click on the form itself, and that message goes BEHIND my application!!!
This could pose some problems and confusions.
If a message is to pop up, it needs to be a HARD message on the screen (just like a VB6 MsgBox)
4. If I set a breakpoint inside that event (ucShellBrowse1_SelectionChanged), I see that when I select a file, that event is fired two times. Sometimes three times.
Is this normal?
5. And last thing: If the user double-clicks on a file (or selects a file and presses Carriage Return), nothing happens.
There is a FileClick event, but there isn't a FileDoubleClick event.
Currently I have a "Process File" commandButton. The user can select a file and then click on that "Process File" commandButton to process the file that he has selected.
What I need to do is to let the user double-click a file (or alternatively, select a file and press Carriage Return) and that file would be processed.
How can I do that?
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
1) I can add an event like SelectionCleared
2) That message comes up when you start a drag and then drop it within the view (but not on a folder or other droptarget). I'll take a look at ways to suppress it.
3) If I can find a way to suppress it that should do the trick; the message originates from Windows though, not the program, so that's why the placement is like that.
4) There's only one single RaiseEvent statement in the entire control for that event; I'll have to see if I can reproduce that issue.
5) The FileExecute event fires on both double-click and return.
I'm going to have to push next release back a day or two, forgot how much work it is to add another navigation button. I'm adding the forward button and the navigation menu dropdown to display a menu containing the nav history.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
#1. In the case of de-selecting a file there are actually two different solutions that come to my mind:
A) Maybe a SelectionCleared event is right as you suggested.
In that case probably the name of that event had better be FileSelectionCleared instead of SelectionCleared (I will explain why below)
B) But, maybe the existing SelectionChanged event can also be tweaked.
In that case when the SelectionChanged event is fired (as a result of deselecting a file), the array arFullPaths() will need to be empty and ucShellBrowse1.SelCount will need to be zero, so that any of the two code snippets in post #34 would work (checking whether the value of ucShellBrowse1.SelCount is zero or checking whether the length of the array arFullPaths() is zero)
Not sure which one of the above two approaches A or B is best.
#2 & #3. I think ucShellBrowse needs a property called AllowDragAndDrop.
And when this property is True, the user can drag and drop, and when it is false, any drag and drop is suppressed.
And last thing is about the name of that event "SelectionChanged".
Honestly, I believe the name of that event should be FileSelectionChanged instead of SelectionChanged
Why? Because there is another event called DirectoryChanged.
How come the name of that other event DirectoryChanged explicitly specifies it is the Directory that has changed, but the name of SelectionChanged event does not explicitly specify what exactly it is that has changed?
We know it is a File that has changed, but the two names are not consistent.
So, I believe for the reason of consistency (and only for consistency), the event SelectionChanged had better be renamed to FileSelectionChanged
Also, if you choose to implement that SelectionCleared event, the name had better be FileSelectionCleared instead of SelectionCleared (Only for the reason of consistency)
Just my humble opinion
Thanks.
Ilia
Last edited by IliaPreston; Feb 18th, 2019 at 04:20 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
I keep experimenting with this control (ucShellBrowse) and if you don't mind, I share my viewpoints and comments.
Hopefully my comments could be helpful.
#6. Currently ucShellBrowse does not provide any possibility for the focus to be set back to a specific file after some user action sets focus to some other control on the screen.
For example: I can click on a file in ucShellBrowse.
That single click selects (highlights) that file. (There will be a light blue rim around the file's thumbnail)
I can now use the arrow keys to freely navigate to other files.
But, if I press Carriage Return, the following code is invoked:
Code:
Private Sub ucShellBrowse1_FileExecute(ByVal sFile As String, siFile As oleexp.IShellItem)
Call cmdFileProcess_Click
End Sub
And then, the focus on the file that was processed is lost. (That light blue rim is now gray instead of light blue, which means that that file is not ACTIVELY selected)
If I want to select that same file again (for the purpose of using arrow keys to navigate to the next file), I cannot set the focus back to that file in the procedure "ucShellBrowse1_FileExecute"
There is no such thing as ucShellBrowse1.SetFocus or ucShellBrowse1.SetFileFocus
So, the user needs to click on that thumbnail again to access it.
This means that a smooth cycle of ArrowKey then Process then ArrowKey then Process, etc. is not currently possible.
The above means that something like a ucShellBrowse1.SetFileFocus or some other way of programmically setting the focus back to that file is needed.
#7. The exact same thing is needed in the very beginning when ucShellBrowse loads the contents of a folder, or when the DirectoryChanged event is fired.
The programmer needs a way to set focus to the first thumbnail that ucShellBrowse shows, so that the user won't have to do a click to select the first file.
8. When I set BackButton = SBBK_ThemeButton, the back button looks like what it does in Windows Explorer, but the "Up" button continues to look the way it does.
It does not follow the setting in the BackButton property, and there is no UpButton property either.
So, when BackButton = SBBK_ThemeButtonm the two buttons' appearances are very different and inconsistent.
Also, in that case (BackButton = SBBK_ThemeButton) the back button moves to the left of the address bar, which doesn't look very good.
It would be nice if the Up button would also look like the Up button in Windows Explorer.
And it would be nice if the Up button would reside next to the Back (and forward) buttons.
All three buttons should be to the right of the address bar, because the address bar should be left aligned with the main body of the ucShellBrowse that contains files.
Thanks
Last edited by IliaPreston; Feb 18th, 2019 at 05:20 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
1) Probably best to do both I would think.
2/3) This option already exists. FileDragDropMode has 4 options: Disabled, Drag Only, Drop Only, and DragDrop
'FileSelectionChange' would imply that the selection change involves a file, but folders are displayed in the ListView as well. One event is for within the ListView, the other is for what location is displayed there. Would really like to avoid breaking backwards compatibility if at all possible; so would suggest that you can rename the event uptop then run a replace for RaiseEvent SelectionChanged,
6) You must be doing something to lose the focus... or maybe what OS are you on? For me I can run code in ucShellBrowse_FileExecute without losing keyboard focus.
In any case, I added a SetFocusOnFiles method that sets focus on the ListView hWnd, should that should take care of it (I'll also add one for the combobox).
For a heads up, Tab-based navigation is not possible. It can be done if it's only just the ListView, but the IOleInPlaceActiveObject hack doesn't work when there's multiple subcontrols on the UC.
7) I'm not sure it's appropriate to select a file the user hasn't picked. Recommend doing this manually instead.
In your Form_Activate event (to cover the initial load), and in the ucShellBrowse_DirectoryChanged event, you can do the following:
Code:
Dim sF() As String
sF = ucShellBrowse1.Files()
If sF(0) <> "" Then ucShellBrowse1.SelectedFile = sF(0)
ucShellBrowse1.SetFocusOnFiles
Note: SetFocusOnFiles is one of the updates I'm working on now, it's not in the release yet; just showing you how you'll do it when the update comes.
8) There is no themed 'Up' navbutton in the Theme API, at least that's documented. Will take a look. Maybe I could at least turn the other buttons into a tool bar; that would look slightly better.
As far as alignment goes, I had went with the standard in Explorer and ComDlg and web browsers for the most part... can probably make an option out of it.
Last edited by fafalone; Feb 18th, 2019 at 07:33 AM.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Originally Posted by fafalone
......
6) You must be doing something to lose the focus... or maybe what OS are you on? For me I can run code in ucShellBrowse_FileExecute without losing keyboard focus.
In any case, I added a SetFocusOnFiles method that sets focus on the ListView hWnd, should that should take care of it (I'll also add one for the combobox).
For a heads up, Tab-based navigation is not possible. It can be done if it's only just the ListView, but the IOleInPlaceActiveObject hack doesn't work when there's multiple subcontrols on the UC.
......
I am using Windows 10 (64bit) on my desktop computer.
Here is the actual code:
Code:
Private Sub ucShellBrowse1_FileExecute(ByVal sFile As String, siFile As oleexp.IShellItem)
Call cmdFileProcess_Click
End Sub
Private Sub cmdFileProcess_Click()
MsgBox "Selected item: " & ucShellBrowse1.SelectedFile, vbOKOnly, "Process"
End Sub
I run the process, then I manually select the first file.
Now, (because the file is SELECTED) I can easily navigate to other files using arrow keys. I do so. I use arrow keys to navigate to another file. It looks like this: https://i.imgur.com/4avLo4y.jpg
Then I press Carriage Return. The above code is invoked, and a messagebox is shown on the screen. It looks like this: https://i.imgur.com/ls4thJe.jpg
Then I press spacebar to close the messagebox and end the process. It looks like this: https://i.imgur.com/mHFW93X.jpg
As you see, at this point the file has a gray rim, and I cannot use arrow keys to navigate to another file until I manually click on that file or manually click on another file to set focus to it.
8) There is no themed 'Up' navbutton in the Theme API, at least that's documented. Will take a look. Maybe I could at least turn the other buttons into a tool bar; that would look slightly better.
As far as alignment goes, I had went with the standard in Explorer and ComDlg and web browsers for the most part... can probably make an option out of it.
All I am saying is that it would be quite good if it would look like this mock-up: https://i.imgur.com/BOakYZd.jpg
Not that it is very important. Just, it would be nice.
Re: [VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive feature
Yeah the messagebox is taking away the focus. The new call I put it will restore the gray to blue.
Without a themed up arrow available from the Theme API, there's going to be the issue of either having the up arrow stored as a static image and therefore not matching on different Windows versions, or storing all of them statically, so they'd match eachother but not Windows except for whatever version I grab the images from. So I'm kind of inclined towards just leaving it as the standard icon that the common dialogs use.
There's a whole lot of code changes involving anything to do with that top row; there's tons of complexity around sizing based on what's showing/hidden, and calculating when to autohide, etc. So it's not as simple as just dragging a control over in the IDE.
BUT... I had a couple hours to kill, so now there's additionally a SBNB_ThemeBtnInBox option that places the back/forward buttons in between the combobox and the up arrow.
So currently like this:
Edit: You had earlier asked about the SelectedFile type functions; it turns out there already are all the permutations you could want...
.SelectedFilePath = full path of selected file, e.g. C:\dir1\file.txt
.SelectedFile = just the name, e.g. file.txt
.SelectedFilesPaths() = array of selected file full paths like above
.SelectedFiles() = array of just selected file names
Also, can't find any time when .SelCount isn't accurate.
So as of right now, the last outstanding issue is what to do about the 'Up', 'View', and 'Bookmarks' button. Probably leaning towards a toolbar; if I did that, you'd be able to replace the icon with your own without it looking too different since text would be optional.
Update (March 1st)
It's funny that I included a comment about almost being feature complete. Then Mr. Preston there came along, and then a bunch of other new features were requested and I thought of a bunch more on top of that. I've been busily working on adding a whole bunch more stuff, that's why the update isn't out yet.
Here's a preview of the changes added so far:
(Removed. Final changelog is posted below in the update announcement; no need for a confusing partial one here.)
But now I *think* I've got everything, except for changing the control command buttons to a toolbar. Hopefully this weekend.
Last edited by fafalone; Mar 8th, 2019 at 10:57 PM.