dcsimg
Results 1 to 20 of 20

Thread: [VB6] ucShellTree: Full-featured Shell Tree UserControl

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Post [VB6] ucShellTree: Full-featured Shell Tree UserControl

    ucShellTree v2.11
    Released 15 Feb 2019

    About
    Designed for navigating the Windows Shell, like my recent Shell Browser Control, ucShellBrowse. This UserControl shows an Explorer-style TreeView of the entire shell, descended from the Desktop like normal. It's very similar to the INamespaceTreeControl in functionality and features, but a manual implementation allows a few extras that aren't available, like automatically handled tri-state checkboxes and open-to-path, and the ability to implement further customizations.

    Key Features
    • Displays complete Explorer-type tree with either Desktop, Computer, or a custom path as the root folder.
    • Tri-state checkboxes show partial selections when check mode is enabled, 4th state with red x is available as an option.
    • Supports drag/drop with modern drag images and drag-over-highlighting (including expanding on hover), based on my cDropTarget project. Can drop on all valid drop targets: folders, zip files, programs, shortcuts to them, etc.
    • Right-click shows the standard Explorer context menu for the clicked item
    • Automatically monitors for changes (item created, deleted, renamed) and updates the tree accordingly.
    • Option to show files as well
    • Can automatically expand to a given path.
    • InfoTips with several lines of details depending on file type are shown as ToolTips
    • Filter option can limit the type of files displayed (or even folders)
    • Can rename in place using LabelEdit
    • Can (optionally) treat .zip/.cab files as a folder
    • Optional additional root entry for 'Favorites' that shows the Links folder.
    • Browses the Network folder too and returns paths as \\Share\etcetc
    • Complete Unicode support


    Works with ucShellBrowse
    This project is similar to my recent ucShellBrowse control, and indeed if you prefer a TreeView to the dropdown for navigation, this control works well with it-- since it can be put into FilesOnly mode. There's a demo project of this setup in the \DemoSB folder (ucShellBrowse DL'd separate, grab the latest version from the ucShellBrowse project thread).


    Requirements
    -Windows Vista or newer
    -oleexp 4.42 or higher (not needed once compiled into OCX)

    Strongly recommended: Common Controls 6.0 Manifest (see here). The Demo projects have a manifest added for when they're compiled, but the IDE and your own projects will need their own. The control works without it, but I haven't fully explored what other things might break without it. This paragraph previously mentioned checkbox issues--- there's no partial checkboxes or exclusion checkboxes but the project now gets the checkboxes from Windows rather than its own, so normal unthemed checks are fine.

    DemoSB: In the DemoSB folder, there's a project that shows the use of ucShellTree with my ucShellBrowse control. This requires ucShellBrowse to be present in the same root as ucShellTree (e.g. C:\vb6\ucShellBrowse and C:\vb6\ucShellBrowse).

    UPDATE - 15 Feb 2019
    Project updated to 2.11 to fix critical bug that prevented the Desktop from being loaded as the root.
    Attached Files Attached Files

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    ucShellTree 2.0 has been released!

    This update brings in a number of new features in addition to some minor bugfixes. The partial checks/autochecking is now optional (and exclusion checks can be added), you can now specify any folder as the root, get/set checks by path, and more. Here's the full changelog:
    Code:
    'v2
    '
    '-You can now specify a custom folder as root*. Changeable during runtime.
    
    '-Added PathGetCheck and PathSetCheck functions. The Set function also has an option to
    ' expand to show the given path in the event it's not yet visible.
    '
    '-The OpenToPath/OpenToItem functions now have an option to just expand to but not select
    ' the item, primarily for the check set function but available in general; default=select.
    '
    '-The .InitialPath property is deprecated. The creation sequence has changed, you can
    ' now just use OpenPath in your Form_Load (or equiv.) event. It remains for compatibility.
    '
    '-Added RootHasCheckbox option to set whether or not one appears (when checkboxes are enabled).
    '
    '-Added ExclusionChecks option, which adds an additional checkbox state- a red x. The .ExcludedPaths
    ' method functions in the same way as the .CheckedPaths method to retrieve paths in this state (they
    ' are not counted as checked).
    '
    '-Added ExplorerStyle option to allow control over whether the Explorer visual style is applied.
    '
    '-Added HorizontalScroll option, to set whether the tree expands without needed HScroll.
    '
    '-Adjusted the RootHasCheckbox option so that if it's changed at runtime, the correct state is set.
    '
    '-Changed disable criteria such that valid file drop targets are excepted from normal disabled prop
    ' list. This was mainly to get the Recycle Bin enabled since it's completely browsable. Other items
    ' remain disabled. (You can change this in TVExpandFolder if desired).
    '
    '-Added Autocheck option for control over whether partial checks are shown and whether parent and
    ' child items are automatically changed according to a new check action.
    '
    '-The control will now fall back to plain checkboxes if no Common Control 6 manifest is present, but
    ' all autocheck functionality is unavailable (even checking all children of a checked parent).
    ' Previously checkboxes were not present at all without a manifest.
    '
    '(Bug fix) The outer edge of the control on dragover indicated a droptarget on no item but
    '          seemingly valid; it now correctly shows no drop is possible.
    '
    '(Bug fix) Invalid (malformed/corrupt) shortcut files caused an error that wasn't handled, so
    '          the item enumeration when expanding a folder stopped when it reached it.
    '
    '(Bug fix) When you call GetParent on your user folder, you get the desktop instead of \Users\,
    '          this caused some issues with auto-navigating.
    '
    '(Control/code) So I thought you needed to supply your own check imagelist for partial checkboxes,
    '               since the extended style wasn't working, but it turned out the problem was just that
    '               you can't set the TVS_CHECKBOXES style; just TVS_EX_PARTIALCHECKBOXES. So the images
    '               have been removed, which eliminates transparency issues and will keep the appearance
    '               the same as the OS.
    '
    '-------
    '* - Technical note: This can be any path string/identifier resolvable by SHCreateItemFromParsingName

  3. #3
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone, Great code I must say. It works awesomely!
    However I have an issue that I do not understand fully.

    I have taken your DEMO.VBP from the DEMO subfolder and added another startup form, named "Form2". On this "Form2" I just have a button that then loads your "Form1" as modal.
    When I close your "Form1", I expect that the Usercontrol_Terminate event would be called, however it does not get called until I close "Form2".

    Typically when a form that hosts a Usercontrol unloads the Terminate event would get fired. Perhaps there are references left over but I cannot find any?

    Can you offer any advise, it would be greatly appreciated.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    I can replicate what you're talking about, but I'm unsure of the cause. First thought was holding an open reference; but since the event isn't even firing cleanup doesn't even start. Other API-based CommonControl project I tested doesn't have this issue, so I'll have to study it further.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    The terminate issue has been resolved, see this thread for details of how it was done (I'm using the fix Eduardo- worked out in post #5), or just update to the new version:

    Version 2.1 has been released!

    In addition to the bugfix that prompted bumping up the new release to tonight, there's several new features and other fixes (including to the Explorer-style issue from post #2 that was there forever). Here's the full changelog:
    Code:
    'v2.11 (Released 15 Feb 2019 - Critical bug fix only)
    '-(Bug fix) Previous fix regarding PathMatchSpecW resulted in always loading the Computer
    '           folder as root.
    '
    'v2.1 (Released 30 Jan 2019)
    '-The font for the TreeView is now a standard property. (Borrowed from Krool's
    ' TreeView. Thanks!)
    '
    '-Shell context menu tips are now passed in the StatusMessage event.
    '
    '-Filter now supports multiple patterns separated by semi-colon.
    '
    '-Replaced Border property with BorderStyle, which has several more options.
    '
    '-(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) Fixed automatic navigation not expanding when a parent of a parent was
    '           collapsed; only the immediate parent was checked previously.
    '
    '-(Bug fix) Custom Roots were checked for validity with PathMatchSpecW, which does
    '           not support virtual locations. Now it's checked by going ahead and trying
    '           to create the IShellItem for it, allowing roots like ::{GUID}
    NOTE: ucShellBrowse, often a companion to this control, has the same bug where UserControl_Terminate doesn't fire. (EDIT: Both projects now have that fixed as of 2.1 for this control, 5.2 for ucShellBrowse)

    UPDATE: 2.11 released for critical bug fix where Desktop could not be selected and the root.

  6. #6
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Thanks to all involved here, added new changes, tested and all is fine now. Awesome work people.

  7. #7
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    The unloading is now fixed, however the other big-fix around the PathMatchSpecW is causing other problems.

    Here is your Demo v2.0:-
    Name:  v2-0.png
Views: 286
Size:  15.0 KB
    You can see that the root is DESKTOP and it shows Libraries, Network.....etc

    Now here is your Demo v2.1:-
    Name:  v2-1.png
Views: 282
Size:  10.9 KB

    You can ignore the difference with the checkboxes, but in the new one you can see that the root is now the COMPUTER, even though I have not supplied a custom root.

    When there is no custom root and it goes into the Sub EnumRoot.... the following code, calling the SHCreateItemFromParsingName returns an siDesk item, so it then sets the bCustRt as True.
    However what it has returned is the Computer.

    In v2.0 code it did the PathFileExistsW(StrPtr(mCustomRoot)) call which failed so it then went onto Call oleexp.SHCreateItemFromIDList(VarPtr(0&), IID_IShellItem, siDesk) which then returned the DESKTOP correctly.


    Code:
    If mComputerAsRoot Then
        oleexp.SHGetKnownFolderItem FOLDERID_ComputerFolder, KF_FLAG_DEFAULT, 0&, IID_IShellItem, siDesk
    Else
        Set siDesk = Nothing
        oleexp.SHCreateItemFromParsingName StrPtr(mCustomRoot), Nothing, IID_IShellItem, siDesk
        If (siDesk Is Nothing) = False Then
            bCustRt = True
        Else
            Call oleexp.SHCreateItemFromIDList(VarPtr(0&), IID_IShellItem, siDesk)
        End If
        TVEntries(0).bDropTarget = True
    End If

    Hope this makes sense, but as I said if you just run the new Demo against the old with no customer root, you should see the difference.

  8. #8
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    I also noticed another issue when attempting to open the Tree to a UNC path.
    If the path was "\\server\FolderOne" for example.
    In v2.0 of the code it would end up crashing out with an Out of Stack Space error.
    It seemed to have an issue once it got the ROOT of this path which was "::{GUID}".
    It just seemed to loop around endlessly at this point and then fail.
    I assume this is what you had found and were trying to fix with the last changes you made relating to the custom Roots.

    In v2.1 of the code it does not crash out, but it does not show the full tree either, and I presume because it is unaware of the NETWORK (see my earlier post).
    Let me know if you need a better example on this one.

    Trev.

  9. #9

  10. #10
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Will post more info on Monday, but if you set the code under the "OPENTO" button in the Demo to open to a path like "\\server\folderone" I would see the problems using v2.0 of the code.
    When it attempted to go back up the path to the root, it would get to a path of "::{GUID}" and then just get caught in a loop and eventually crash.

  11. #11
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    Here is more information regarding Network paths, and the differences that we now have between 2.0 and 2.1 code, and the problem I faced with 2.0 code.

    Scenario:-
    The Tree is loaded, no custom root has been offered so the root is being determined by the 2.1 code.
    We then issue a call to -
    Code:
    ucShellTree1.OpenToPath "\\server\nonbackup\Folder1\Folder2\Folder3\Mykra", True


    Here is the result from v2.1 code:-
    Name:  UCShell2-1.png
Views: 237
Size:  11.7 KB

    I have also attached the DEBUG trace output of the above.
    UCShellTree2-1 results.txt
    As you can see the Network branch is no longer shown in 2.1 and when OpenToPath is issued, all it does is just add the "Mykra" to the tree, with no parent, or expand folders.

    Result from 2.0 code:-
    Name:  v2-0.png
Views: 234
Size:  15.0 KB

    No image after call to "OpenToPath" as it crashes with an "Out of Stack Space" error.
    The DEBUG trace file is attached, albeit shortened as it just keeps repeating.
    UCSHELLOUTPUT.txt

    Details for the UNC path I am using.
    SERVER is the name of a file server I have.
    nonbackup is a shared folder on the server
    Folder1, Folder2, Folder3 and Mykra are just subfolders.

    I hope this helps. Let me know if you need anything further.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Does fixing the first not fix the second, or had you not applied that change? (What I did was check mCustomPath wasn't blank). I've been really busy this week I'll update things tomorrow.

    Adding the folder without a parent is by-design though; it was made for virtual locations that can be opened but don't have parents; so if a location is valid, but a parent can't be found, it inserts under the root. Once the 'Network' is back it will add under that.

    Edit: Project updated to 2.11 to address Desktop not loading as root issue. If this doesn't fix the other issues too we can revisit but in the meantime I had to get a fix out for a bug that severe.

  13. #13
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Will check again with new 2.11 code on Monday and come back to you. Thanks Fafalone.

  14. #14
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    I can confirm that v2.11 resolves the missing Desktop.

    I can also confirm that there is still just a very small issue with Network browsing (or any path for that matter, depending on the string value passed).

    In my case my Network path still failed and hit your loop limit of 100, because the PATH used was "\\server\nonbackup\Folder1\Folder2\Folder3\Mykra".
    The Function GetMapIdxByPath never found a match for the "server" because when it was populated into the TVVisMap it was in UPPERCASE, and we were passing it lowercase. Seems like all Network computers are returned UPPERCASE.

    To resolve this I just adjusted this function as follows by adding in the UCASE$ statements.

    Code:
    Private Function GetMapIdxByPath(sFullPath As String) As Long
    Dim i As Long
    
        For i = 0 To UBound(TVVisMap)
            If UCase$(TVVisMap(i).sFullPath) = UCase$(sFullPath) Then
                GetMapIdxByPath = i
                Exit Function
            End If
        Next i
        GetMapIdxByPath = -1
    
    End Function
    Please advise if there was a better way of handling this.

    Thanks for this work Fafalone, the code is awesome.

  15. #15

  16. #16
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    Further to my previous note about adding Ucase$ into the GetMapIdxByPath function, it should probably be also added to the GetNodeByPath function as well, like below:-

    Code:
    Private Function GetNodeByPath(sFullPath As String) As Long
    Dim I As Long
    
        For I = 0 To UBound(TVEntries)
            If UCase$(TVEntries(I).sFullPath) = UCase$(sFullPath) Then
                GetNodeByPath = TVEntries(I).hNode
                Exit Function
            End If
        Next I
        GetNodeByPath = -1
    
    End Function
    Cheers.
    sabbath69

  17. #17
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    I have discovered an issue with attempting to OpenPath to the User's DESKTOP folder.

    If you attempt to "C:\Users\Trevor\DESKTOP" it will fail and not find anything in the TVNavigate sub.

    Cheers!

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    If you look down in TVNavigate, you'll see I had already encountered a similar bug; there's issues with properly returning the parent of user folder items.
    In the case of navigating to the desktop, it returns nothing for the parent of the desktop; which is generally true, as it's also the navigation root--- if you keep requesting parents you always wind up at the desktop.
    So here's a temporary fix, but I'm going to have to look into the possible consequences of sometimes treating it as root and sometimes not (although the root is internally defined as "0" so I'm hoping it's ok).

    After the If idx > -1 block, not within it but after it, there's the statement
    si.GetParent siPar
    replace that line with the following
    Code:
    If sFull = sUserDesktop Then
        SHGetKnownFolderItem FOLDERID_Profile, KF_FLAG_DEFAULT, 0&, IID_IShellItem, siPar
    Else
        si.GetParent siPar
    End If
    All those vars/functions are already declared so that's the only change to make.

  19. #19
    Member
    Join Date
    Jul 2008
    Posts
    41

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    Fafalone,

    I have a Feature Request. (or some guidance on how I could implement)

    Another Tree control that I used to use, had a nice feature that was the ability to load/expand to a folder path without traversing all other folders. "Fast" mode if you like.
    This enabled great speed and removed some of the overhead of adding all other folders, but still gave the user the ability to expand any folder if they desired.

    Example -
    Open to this folder = "\\server\NonBackup\Folder1\Folder2\Folder3"

    Would produce this sort of result
    Name:  tree.png
Views: 79
Size:  11.3 KB

    As you can see the folders are listed and expanded, although they still have the "+" icon so they can be expanded by the user if desired.


    I have tried to have a go myself at adding such a feature, but have struggled basing it on some of you existing routines.
    I can see how to add items, but cannot determine how to add a child item and have the Parent expanded, but still keep the "+" icon so that it thinks it is not expanded.

    Do you think this you would be able to offer some advise on how I could get this added.

    Thanks.
    sabbath69

  20. #20

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,193

    Re: [VB6] ucShellTree: Full-featured Shell Tree UserControl

    I'm familiar with what you're talking about. It's a good idea and I'll work on it; but it's going to need an entirely new autonavigate function, and might have to change the way the whole directory loading works. So can't put a timeframe on it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width