Page 3 of 6 FirstFirst 123456 LastLast
Results 81 to 120 of 223

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

  1. #81
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Code:
                    ElseIf ((nmtvic.uStateNew And TVIS_STATEIMAGEMASK) = &H3000) And (mAutocheck = False) Then
                        DebugAppend "ItemExclude"
                        If mExCheckboxes Then
                            TVEntries(nmtvic.lParam).Checked = False
                            TVEntries(nmtvic.lParam).Excluded = True
                        Else
                            SetTVItemStateImage nmtvic.hItem, tvcsEmpty
                        End If
    Confirmed. These changes resolve the Tri-State-Bug when setting .Checkboxes = True in the code (control properties: Autocheck=false, Checkboxes=false, ExclusionChecks=false)

  2. #82
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Sorry, but i found another bug :-)

    control properties:

    Code:
    Autocheck=false
    Checkboxes=True
    ExclusionChecks=false
    Form_Load:

    Code:
    ucTree.Checkboxes = False
    MSDN TVS_CHECKBOXES Description:

    Once a tree-view control is created with this style, the style cannot be removed. Instead, you must destroy the control and create a new one in its place.
    You have to rebuild the treeview again in the "Public Property Let Checkboxes" if set to FALSE. Destroy the TV and call "InitTV" again?

  3. #83
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    i found some more bugs while testing the control:

    1. ExpandZip is set to false but the zip file stills expands.

    2. ItemClick event: the variable bFolder returns True if i click on a ZIP file.

    control properties:

    Code:
    ExpandZip=false
    ShowFiles=True
    Autocheck=false
    Checkboxes=false
    ExclusionChecks=false

  4. #84
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by Mith View Post
    2. ItemClick event: the variable bFolder returns True if i click on a ZIP file.
    Fix:

    Func "ucWndProc", Case NM_CLICK, Case NM_RCLICK

    Code:
    Dim b_isFolder As Boolean
    
    If TVEntries(tVI.lParam).bZip = True Then
          b_isFolder = False
    Else
          b_isFolder = TVEntries(tVI.lParam).bFolder
    End If
    RaiseEvent ItemClick(TVEntries(tVI.lParam).sName, TVEntries(tVI.lParam).sFullPath, b_isFolder, MK_LBUTTON, tvhti.hItem)
    RaiseEvent ItemClickByShellItem(siSelected, TVEntries(tVI.lParam).sName, TVEntries(tVI.lParam).sFullPath, b_isFolder, MK_LBUTTON, tvhti.hItem)
    Now the variable bFolder returns False for ZIP files.

  5. #85

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    No need to apologize for bug reports-- I'm sorry they're needed, but I definitely want to get them so I can fix it.

    --
    Post 82-- Try .RefreshTreeView() after changing the check; that destroys and recreates-- I spent tons of time working out how to restore the expansion states of the filesystem too, so it won't go back to startup state (if you want that, .ResetTreeView). I'll add in routine to this automatically if transitioning from checked to unchecked.


    Post 83-- If ShowFiles = False, I can't reproduce this-- it correctly excludes zip files. If ShowFiles = True, then it's by design-- perhaps it's not the best name; ExpandZip is more along the lines of 'treat zip as folder'; I hadn't set it up to treat a zip as a file but block expansion anyway.

    Post 84 - This is the same design issue. If ExpandZip is True, a zip *should be* reported as a folder (as Explorer does). I'll modify that block to check that setting, but it will still return bFolder = True when ExpandZip = True.


    ---

    Actually, try this:

    In TVAddItem, prior to TVEntries(nCur).sFullPath = sFPP, add this block:

    Code:
            If (mShowFiles = True) And (mExpandZip = False) Then
                If (bFolder = True) And (bZip = True) Then
                    bFolder = False
                End If
            End If
    Also add that in TVExpandFolder, just before TVEntries(nCur).sFullPath = LPWSTRtoStr(lpFull)
    That should resolve issues globally instead of just at the click spot, because it impacts drag/drop too.
    Last edited by fafalone; Jan 27th, 2024 at 12:39 PM.

  6. #86
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post

    Code:
            If (mShowFiles = True) And (mExpandZip = False) Then
                If (bFolder = True) And (bZip = True) Then
                    bFolder = False
                End If
            End If
    Your code snippet fixed the problem for ShowFiles=True & ExpandZip=false. The variable bFolder returns now True in the ItemClick event if i click on a ZIP file.

  7. #87
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Post 82-- Try .RefreshTreeView() after changing the check; that destroys and recreates-- I spent tons of time working out how to restore the expansion states of the filesystem too, so it won't go back to startup state (if you want that, .ResetTreeView). I'll add in routine to this automatically if transitioning from checked to unchecked.
    I tried both (RefreshTreeView & ResetTreeView) and they don't remove the checkboxes in the the control:

    Code:
    control properties: Checkboxes = True
    
    Private Sub Form_Load()
             ucTree.Checkboxes = False
             'ucTree.RefreshTreeView
             ucTree.ResetTreeView
    End Sub

  8. #88
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Event bug:

    You only raise the event "ItemCheck" if Autocheck=True. See unWndProc -> TVN_ITEMCHANGEDW.
    The event "ItemCheck" should also raised if AutoCheck=False.

    Fix:

    Add this line:

    Code:
    RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, CLng(Abs(TVEntries(nmtvic.lParam).Checked)), nmtvic.hItem)
    to ucWndProc -> TVN_ITEMCHANGEDW

    Code:
    If (nmtvic.uStateNew And TVIS_STATEIMAGEMASK) = &H1000 Then
        TVEntries(nmtvic.lParam).Checked = False
        TVEntries(nmtvic.lParam).Excluded = False
        RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, CLng(Abs(TVEntries(nmtvic.lParam).Checked)), nmtvic.hItem)
    
    ElseIf (nmtvic.uStateNew And TVIS_STATEIMAGEMASK) = &H2000 Then
        TVEntries(nmtvic.lParam).Checked = True
        TVEntries(nmtvic.lParam).Excluded = False
        RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, CLng(Abs(TVEntries(nmtvic.lParam).Checked)), nmtvic.hItem)
    What about &H3000 and &H4000?
    Last edited by Mith; Jan 27th, 2024 at 07:14 PM.

  9. #89
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Question ucTree Enhancement "ShowOnlyFileCheckboxes"

    ucTree Enhancement "ShowOnlyFileCheckboxes"

    Situation:

    A user should select some files via checkboxes but not select any folders via the checkboxes.

    Solution:

    A solution could be to show checkboxes only for files using a control property like "ShowOnlyFileCheckboxes".

    Current solution:

    Currently i modified the ItemCheck event to respond to changes of the variable fCheck to change back the Check-State if necessary:

    Code:
    ucWndProc -> TVN_ITEMCHANGEDW
    
    If (nmtvic.uStateNew And TVIS_STATEIMAGEMASK) = &H1000 Then
        TVEntries(nmtvic.lParam).Checked = False
        TVEntries(nmtvic.lParam).Excluded = False
        i = CLng(Abs(TVEntries(nmtvic.lParam).Checked))
        lSel = i
        RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, lSel, nmtvic.hItem)
        If lSel <> i Then
          TVEntries(nmtvic.lParam).Checked = True
          SetTVItemStateImage nmtvic.hItem, tvcsChecked
        End If
        
    ElseIf (nmtvic.uStateNew And TVIS_STATEIMAGEMASK) = &H2000 Then
        DebugAppend "ItemCheck"
        TVEntries(nmtvic.lParam).Checked = True
        TVEntries(nmtvic.lParam).Excluded = False
        i = CLng(Abs(TVEntries(nmtvic.lParam).Checked))
        lSel = i
        RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, lSel, nmtvic.hItem)
        If lSel <> i Then
          TVEntries(nmtvic.lParam).Checked = False
          SetTVItemStateImage nmtvic.hItem, tvcsEmpty
        End If
    Code:
    Private Sub ucFiles_ItemCheck(sName As String, sFullPath As String, bFolder As Boolean, fCheck As Long, hItem As Long)
    If bFolder = True And fCheck = 1 Then
       fCheck = 0 ' dont allow check folders & others
    End If
    End Sub
    What do you think?
    Last edited by Mith; Jan 27th, 2024 at 07:57 PM.

  10. #90

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    Quote Originally Posted by Mith View Post
    I tried both (RefreshTreeView & ResetTreeView) and they don't remove the checkboxes in the the control:

    Code:
    control properties: Checkboxes = True
    
    Private Sub Form_Load()
             ucTree.Checkboxes = False
             'ucTree.RefreshTreeView
             ucTree.ResetTreeView
    End Sub
    Try this:
    Code:
    Public Sub HardResetTreeView()
    If Ambient.UserMode Then
       DestroyWindow hTVD
       pvCreate
    End If
    End Sub
    Public Sub HardRefreshTreeView()
    'Resets to the root then expands all the previous locations
    'The lengthy code involves minimizing the OpenToPath calls by calculating
    'smallest group of folders that will give us the same setup. E.g.:
    'C:\a\b\(c,d,e,f) will call only C:\a\b\c, and not d,e,f or C:\a or b, because
    'expanding to c will give us a b d e and f too
    Dim i As Long
    Dim sData() As String
    
    If CalcRefreshData(sData) Then
        HardResetTreeView
        
        For i = 0 To UBound(sData)
            OpenToPath sData(i), False
        Next i
    End If
    OpenToPath sSelectedItem, False, True
    Exit Sub
    e0:
        DebugAppend "PruneParentsFromRPL.Error->" & Err.Description & "(0x" & Hex$(Err.Number) & ")"
    
    End Sub
    You only raise the event "ItemCheck" if Autocheck=True. See unWndProc -> TVN_ITEMCHANGEDW.
    The event "ItemCheck" should also raised if AutoCheck=False.
    Good catch-- I think you should have it *only* at the spots your fix puts, otherwise it would fire twice when AutoCheck = True. Will include in next release, thanks.

    &H3000 and &H4000 are partial check and exclusion check; they shouldn't raise a check event. Perhaps a new event should be added for ItemExclude, but it really shouldn't be a check event.

    A user should select some files via checkboxes but not select any folders via the checkboxes.
    You're of course welcome to modify ucShellTree but I think that's going a little beyond scope-- you'd be better off pairing a ucShellTree with ucShellBrowse; you could set the latter to turn off the top bar, hide folders, and show checkboxes, with the folder tree to the side for navigation.

    Like this, but with Checkboxes = True for the ucShellBrowse control:

    Name:  ez0LXoT.jpg
Views: 204
Size:  78.5 KB
    Last edited by fafalone; Jan 28th, 2024 at 01:21 AM.

  11. #91
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    helper function addon

    I added a useful helper function to the control:

    Code:
    Public Property Get CheckedPathCount() As Variant
        CheckedPathCount = GetCheckedPathCount
    End Property
    
    Private Function GetCheckedPathCount() As Long
    Dim i As Long
    Dim lCount As Long
    lCount = 0
    For i = 0 To UBound(TVEntries)
        If (TVEntries(i).Checked = True) And (TVEntries(i).bDeleted = False) Then
            lCount = lCount + 1
        End If
    Next i
    GetCheckedPathCount = lCount
    End Function
    This helps to decide e.g. to enabled or disabled a OK-button on a dialog window.

    Do you have any explanation why i can't return a LONG with this helper function? The control crahses when i return a LONG...

  12. #92
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    You're of course welcome to modify ucShellTree but I think that's going a little beyond scope-- you'd be better off pairing a ucShellTree with ucShellBrowse; you could set the latter to turn off the top bar, hide folders, and show checkboxes, with the folder tree to the side for navigation.
    That's not possible, because the user must have the possibility to select files from different directories/drives. Thats the reason i switched from CommonDialogs to this ShellTree!

  13. #93
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Good catch-- I think you should have it *only* at the spots your fix puts, otherwise it would fire twice when AutoCheck = True. Will include in next release, thanks.
    How about to add this before the event-raise for check/uncheck?

    Code:
    if AutoCheck = false then
                          i = CLng(Abs(TVEntries(nmtvic.lParam).Checked))
                          lSel = i
                          RaiseEvent ItemCheck(TVEntries(nmtvic.lParam).sName, TVEntries(nmtvic.lParam).sFullPath, TVEntries(nmtvic.lParam).bFolder, lSel, nmtvic.hItem)
                          If lSel <> i Then
                            TVEntries(nmtvic.lParam).Checked = True
                            SetTVItemStateImage nmtvic.hItem, tvcsChecked
                          End If
    
    end if

  14. #94
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    BorderStyle property bug

    I found another bug:

    The change of the control property BorderStyle isnt stored because at UserControl_ReadProperties you read the property with the name "Border" but you save the property with the name "BorderStyle".

    Easy to fix

  15. #95

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

    Re: helper function addon

    Quote Originally Posted by Mith View Post
    I added a useful helper function to the control:

    Code:
    Public Property Get CheckedPathCount() As Variant
        CheckedPathCount = GetCheckedPathCount
    End Property
    
    Private Function GetCheckedPathCount() As Long
    Dim i As Long
    Dim lCount As Long
    lCount = 0
    For i = 0 To UBound(TVEntries)
        If (TVEntries(i).Checked = True) And (TVEntries(i).bDeleted = False) Then
            lCount = lCount + 1
        End If
    Next i
    GetCheckedPathCount = lCount
    End Function
    This helps to decide e.g. to enabled or disabled a OK-button on a dialog window.

    Do you have any explanation why i can't return a LONG with this helper function? The control crahses when i return a LONG...
    Try ()?

    Code:
    Public Property Get CheckedPathCount() As Long
        CheckedPathCount = GetCheckedPathCount()
    End Property
    I've seen some weird bugs around () before.

    That's not possible, because the user must have the possibility to select files from different directories/drives. Thats the reason i switched from CommonDialogs to this ShellTree!
    Strictly speaking it would be; you'd just cache the check status on your end to combine from multiple folders and restore it if needed. But yes ucShellTree is better for this. You could in theory remove the checkboxes from folders by setting the state image index to 0... it would require some doing, I'll look into it as a feature for next version. I'll be doing big work on these controls again soon now that twinBASIC's new version is out (ucShellTree is currently not working on it so not for another few days).

    How about to add this before the event-raise for check/uncheck?
    Was there an issue with how I was going to set it up? I haven't tested it yet, no time right now.

  16. #96
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Feature request: "ShowHiddenFileExtensions"

    Feature request: "ShowHiddenFileExtensions":

    Your control supports ShowHiddenItems & ShowSuperHidden but i miss a property to enable the forced display of file extensions to override the system settings of the windows explorer.

    Is that possible?

  17. #97
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Exclamation VB crashes using the control as an OCX

    VB6SP6 Win10x64

    I compiled your control as an OCX and use binary compatibility to avoid multiple ClassIDs for each new compiled OCX.

    Now VB6 crashes everytime when i start my test project in the IDE and a form with the control is displayed.
    This also happens when i run the test project as an compiled EXE.

    I get no crash if i open the form with the control in the IDE and edit some properties.

    Info: No crash happens if i compile the OCX without any compatibility but this no pratical solution.

    How to use the ShellTree as an OCX with binary compatibility?

  18. #98

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

    Re: Feature request: "ShowHiddenFileExtensions"

    Quote Originally Posted by Mith View Post
    Feature request: "ShowHiddenFileExtensions":

    Your control supports ShowHiddenItems & ShowSuperHidden but i miss a property to enable the forced display of file extensions to override the system settings of the windows explorer.

    Is that possible?
    Certainly possible; ucShellBrowse has such an option. Just takes a bit of work to set up correctly; you can't just switch the name queried for everything because then you wind up showing extensions that should be hidden even when extensions are shown (e.g. .lnk on shortcuts) and GUIDs for some virtual items.

    How to use the ShellTree as an OCX with binary compatibility?
    I really don't know too much about this since I never use them as ocx myself beyond test compiles; I think it's a general issue rather than ucShellTree-specific so a thread about it might get some answers; you may need to unregister and delete the previous versions if you want to compile with binary compatibility, because I think that problem arises when you compile it and it's *not* actually compatible.

  19. #99
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Re: Feature request: "ShowHiddenFileExtensions"

    Quote Originally Posted by fafalone View Post
    I really don't know too much about this since I never use them as ocx myself beyond test compiles; I think it's a general issue rather than ucShellTree-specific so a thread about it might get some answers; you may need to unregister and delete the previous versions if you want to compile with binary compatibility, because I think that problem arises when you compile it and it's *not* actually compatible.
    I posted a question to the VB6 group: OCX crashes when compiled with binary compatibility

    But i guess it have something to do with your code because i use a lof of OCXs with binary compatibility and never had any issue until today.

    I guess i will add debug code to the OCX to check where exactly the OCX crashes. Stay tuned for the result...

  20. #100
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Re: Feature request: "ShowHiddenFileExtensions"

    The compiled OCX with binary compatibility crashes in the function CreateTreeView at the line CreateTreeView = CreateWindowEx(...)

    Code:
    Private Function CreateTreeView(hwndParent As Long, _
                                                        iid As Long, _
                                                        dwStyle As Long, _
                                                        dwExStyle As Long) As Long
       DebugToFile "CreateTreeView_Start"
      Dim rc As oleexp.RECT ' parent client rect
       Call GetClientRect(hwndParent, rc)
       DebugToFile "CreateTreeView_1"
      ' Create the TreeView control.
      CreateTreeView = CreateWindowEx(dwExStyle, WC_TREEVIEW, "", _
                                                    dwStyle, 0, 0, rc.Right, rc.Bottom, _
                                                hwndParent, iid, App.hInstance, 0)
    DebugToFile "CreateTreeView_End"
    
    End Function
    Debug values before CreateWindowEx:

    Code:
    dwStyle: 1350638121     
    rc.Right: 297           
    rc.Bottom: 340          
    hwndParent: 3348196     
    iid: 100                
    App.hInstance: 285212672
    Do you have any idea whats going on?

  21. #101
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Cool Double trouble folder display bug

    I found another bug:

    The folder "C:\test1" is root but showed again inside himself as a sub folder:

    ShellTree:

    Name:  ucTree.png
Views: 199
Size:  35.0 KB

    Windows Explorer:

    Name:  explorer.png
Views: 195
Size:  50.5 KB

    Code to reproduce:

    Code:
    ucTree.CustomRoot = "C:\test1"
    ucTree.OpenToPath "C:\test1", True
    Solution:

    Avoid using OpenToPath with a path that is used as CustomRoot or add this to the OpenToPath function:

    Code:
    if OpenToPath = CustomRoot then Cancel OpenToPath

  22. #102

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    Yeah I didn't put in too many checks against the user shooting themselves in the foot But I'll add that check.

  23. #103
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Check/Uncheck item visually select issue

    Check/Uncheck item visually select issue

    A item isnt selected when checking or unchecking the item.

    Here i checked the item "DVD" but the item "Boot" is still selected:

    Name:  item not selected after check or uncheck.jpg
Views: 195
Size:  10.4 KB

    IMHO it should be like this:

    Name:  item selected.png
Views: 174
Size:  26.2 KB

    How can i select the item in the ItemCheck event using the variable hItem?

  24. #104

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    TreeView_SetItemState hTVD, hItem, TVIS_SELECTED, TVIS_SELECT

    But I definitely wouldn't want that behavior so if I add it, it would be a default-off option. Note it's probably going to trigger all the code that fires when you click the item; if it does, to avoid it you'd have to set a module-level flag like 'bIgnoreThisSelection' and set it before then clear it after, then wrap all the selected item code in it.

  25. #105
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    TreeView_SetItemState hTVD, hItem, TVIS_SELECTED, TVIS_SELECT
    I tried it with SendMessage inside the ItemClick event but it doesnt work:

    Code:
    Public Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Private Sub ucTree_ItemCheck(sName As String, sFullPath As String, bFolder As Boolean, fCheck As Long, hItem As Long)
    Const TV_FIRST = &H1100
    Const TVM_SELECTITEM = (TV_FIRST + 11)
    Const TVGN_CARET = &H9
    Debug.Print "hWndTreeView:"; ucTree.hWndTreeView
    Debug.Print "hItem:"; hItem
    Debug.Print SendMessageAny(ucTree.hWndTreeView, TVM_SELECTITEM, TVGN_CARET, hItem)
    End Sub
    Debug values:

    Code:
    hWndTreeView: 4659090 
    hItem: 230647432 
     0
    Strange, you use the same SendMessage call in the CTL to select an item but in the ItemClick event it doesnt work.

    Any ideas?

  26. #106
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    Question Create new folder

    The SHBrowseForFolder dialog supports the creation of new folders in the tree.

    Is this somehow possible with ucShellTree too?

    e.g. add a new TreeViewItem and start the Label edit mode to set the name of the new folder.

  27. #107

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    Thought I added that already... guess not... ucShellBrowse can... Will do. Going to need a few days though my Windows install went insane I'm going to be down a couple days for a reinstall, can't do any serious programming on my tablet.

  28. #108
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Going to need a few days though my Windows install went insane I'm going to be down a couple days for a reinstall, can't do any serious programming on my tablet.
    Install and use VB6 inside a virtual machine like VMware. Easy to reset to the default installation. No heavy reinstallation & configuration of your dev environment needed

  29. #109

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    I have tB on my tablet its just a pain to use and im focused on fixing things. I'm done backing up files and making install media so hopefully by tonight; vb6 and tB get reinstalled first.

  30. #110
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Expanding a zip when ShowFiles = True is by design; as I explained it's more of a poorly named property issue.

    What I'll do for you is add a module level property, mNeverExpandZip, in the User Options section up top below the changelog.

    Then in TVExpandFolder,
    Code:
     ...
    and in TVAddItem,
    Code:
          ...
    How can i display the .ZIP extension in the tree?

    Name:  zip files no extensions.png
Views: 147
Size:  6.1 KB

    For the user it is confusing without the file extension.
    The first and second zip file looks like a folder and the 3. zip file looks like a txt file...

    my ucShellTree properties:

    Code:
    ShowFiles = True
    mNeverExpandZip = True
    ExpandZip = False
    i guess something like this should be added:

    Code:
    if ShowFiles = True AND mNeverExpandZip = True AND ExpandZip = False then ShowZipExtension=True

  31. #111

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    Hiding extensions is one of the worst default settings of Windows ever yet they've refused to correct that for decades despite being bad for usability and worse for security.

    The option to always show extensions or use explorer will be in the next version. If you want to test if it's working right for me and/or backport from tB to VB6, https://github.com/fafalone/ShellCon...ellTree2-9-2-a

    If you're still refusing to join us in the future, you can view ucShellTree.twin as text in the browser, it's the source code file for the control.

    The changes are much more substantial than the others; a lot more sections had to be changed and rearranged for this, too many to put into this post.

    Code:
    'v2.9.2 (ALPHA, 29 Jan 2024)
    '-New FileExtensions property to choose between following Explorer's setting for hiding
    ' known extensions, over forcing them to always show.
    '
    '-Added property CheckedPathCount.
    '
    '-Added UserOption mNeverExpandZip, to prevent expansion of .zip when ShowFiles = True.
    '
    '-(Bug fix) Border property not restored correctly due to re-reading it with the wrong
    '           name from the property bag.
    '
    '-(Bug fix) Opening to a custom root would add the root as a child of itself.

  32. #112
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    If you're still refusing to join us in the future, you can view ucShellTree.twin as text in the browser, it's the source code file for the control.
    The changes are much more substantial than the others; a lot more sections had to be changed and rearranged for this, too many to put into this post.
    I transfered all your changes from the Twinbasic control to the VB6 control but now i see that your changes make it impossible to use them in the VB6 CTL file.

    You added Krool's subclassing and this requires the use of an external module for the subclassing functions. The use of the AddressOf operator doesnt work if the sublass functions are not in a module...

  33. #113

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    I use not only ucShellTree as a ctl exclusively, but also Krool's VBCCR and VBFlexGrid controls, exclusively, as ctl. I assure you it's not impossible, it just requires having a standard module as a helper.

    But the method of subclassing isn't of particular importance. You could leave the old IPAO/subclassing routines and just port the substantive code changes.

    ucShellTree and ucShellBrowse was the very first project I ported... was just excited to try out tB and didn't think to keep the code completely compatible. I was thinking more along the lines of 'look for the FileExtensions property, it's associated variable and property, and add those in' rather than backport the entire project... that's going to be much more work. There's changes to be made to switch between WinDevLib and oleexp.tlb too. And IIRC I used tB syntax in other places. Later projects I tried to keep the code of existing projects compatible, but I've never gotten around to wholesale backporting the new ucShellTree/ucShellBrowse versions.

  34. #114
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,022

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

    Quote Originally Posted by Mith View Post
    The use of the AddressOf operator doesn't work if the sublass functions are not in a module...
    Even if the "WndProc" needs to reside in a module as to accommodate the "AddressOf" operator, all it does is forward messages to any of your classes that implement the "ISubclass" interface:

    Code:
    Private Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal Subclass As ISubclass, ByVal dwRefData As Long) As Long
        Select Case uMsg
            Case WM_NCDESTROY
                UnSubclassWnd hWnd: WndProc = DefSubclassProc(hWnd, uMsg, wParam, lParam)
            Case Else
                WndProc = Subclass.WndProc(hWnd, uMsg, wParam, lParam, dwRefData)
        End Select
    End Function
    ISubclass.cls
    Code:
    Public Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal dwRefData As Long) As Long
    
    End Function
    I haven't looked at Krool's controls but isn't he using the same subclassing method? It's pretty "boiler plate"...

  35. #115
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    I transfered all your changes from the Twinbasic control (v2.9.2) to the VB6 control excluding the Subclassing.

    The control is running but now something is strange:

    ucTree.OpenToPath "C:", True

    Name:  opentopath.png
Views: 115
Size:  55.0 KB

    drive C should be displayed under Computer and not as a child of the Desktop.


    Expanding some items:

    Name:  expand.png
Views: 123
Size:  158.3 KB

    control properties:

    Code:
    ShowFavorites = False
    Checkboxes = True
    ShowFiles = False
    AutoExpandComputer = False
    AutoExpandLibraries = False
    ShowQuickAccessOnWin10 = false
    How to fix that?

  36. #116
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by Mith View Post
    I transfered all your changes from the Twinbasic control (v2.9.2) to the VB6 control excluding the Subclassing.

    The control is running but now something is strange:
    I checked the code between Twinbasic and VB6 again and found the problem!

    Everything looks fine again!

    I'll test some more and then report back.

  37. #117
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

    crash: ExtendedOverlays=True

    VB6SP6, Win10x64, uShell 2.9.2

    I miss the overlay icons for LNK files, junctions and symbolic links in the tree.

    Windows Explorer:

    Name:  windows explorer link overlay icons.png
Views: 111
Size:  11.1 KB

    ucShellTree:

    Name:  ucShellTree no overlay icons.png
Views: 116
Size:  35.1 KB

    I set .ExtendedOverlays = True to get this overlay icons but the app/ide crashes when displayed.

    Does ExtendedOverlays show the missing overlay icons or is this a new feature to add?

    Code:
    'v2.17 (Released 15 Mar 2020)
    '
    '-(Bug fix) The default overlays that should always stay on weren't showing (Link/Share)
    Last edited by Mith; Feb 1st, 2024 at 07:36 PM.

  38. #118

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,269

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

    Extended overlays is for overlays besides links/junctions and shares; if you turn off extended overlays, the simple ones should still show:

    Code:
            lpIconOvr = -1
            If mExtOverlay Then
                Set pIconOvr = psf
                pIconOvr.GetOverlayIndex pidlRel, lpIconOvr
            End If
            If (lpIconOvr > 15) Or (lpIconOvr < 0) Then
                'Overlay icons are a mess. On Win7 there's a bunch in root that return 16, which is invalid
                'and will cause a crash later one, and doesn't show anything. Shares never get shown so I'm
                'going to manually set those
                lpIconOvr = -1
                If (lAtr And SFGAO_SHARE) = SFGAO_SHARE Then
                    lpIconOvr = 1
                End If
                If (lAtr And SFGAO_LINK) = SFGAO_LINK Then
                    lpIconOvr = 2
                End If
            End If
    But it looks like a bug. Not sure how it happened because I specifically made sure it was working before I released the icon size update a few weeks ago.

    I think Windows uses one or two more in some cases but it's mostly for apps that install custom ones; not too many do because there's a global system limit of 15. I'll investigate the crashing and why it's failing to show the overlays despite no errors setting them; the code is taken from ucShellBrowse where they're still working.

  39. #119
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    Quote Originally Posted by fafalone View Post
    Extended overlays is for overlays besides links/junctions and shares; if you turn off extended overlays, the simple ones should still show:
    With ucShell v2.7 the overlay icons are visible but the icon for a junction is wrong:

    Name:  ucShellTree27.png
Views: 108
Size:  11.4 KB

    A junction uses a different icon than a symbolic link or a shortcut:

    Name:  windows explorer link overlay icons.png
Views: 97
Size:  11.1 KB

    I guess the problem with the missing overlay icons is triggered by the new function EnsureOverlay:

    Code:
            lpIconOvr = -1
            If mExtOverlay Then
                Set pIconOvr = psf
                pIconOvr.GetOverlayIndex pidlRel, VarPtr(lpIconOvr)
            End If
            If (lpIconOvr > 15) Or (lpIconOvr < 0) Then
                'Overlay icons are a mess. On Win7 there's a bunch in root that return 16, which is invalid
                'and will cause a crash later one, and doesn't show anything. Shares never get shown so I'm
                'going to manually set those
                lpIconOvr = -1
                If (lAtr And SFGAO_SHARE) = SFGAO_SHARE Then
                    lpIconOvr = 1
                End If
                If (lAtr And SFGAO_LINK) = SFGAO_LINK Then
                    lpIconOvr = 2
                End If
            End If
            EnsureOverlay lpIconOvr

  40. #120
    Hyperactive Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    455

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

    I debugged a little bit and it's not the new function "EnsureOverlay" because after this function returns the value of lpIconOvr is still 2 (LINK).

    I guess there is something wrong with the ImageList that stores the overlay icons...

    Quote Originally Posted by Mith View Post
    I guess the problem with the missing overlay icons is triggered by the new function EnsureOverlay:

    Code:
            lpIconOvr = -1
            If mExtOverlay Then
                Set pIconOvr = psf
                pIconOvr.GetOverlayIndex pidlRel, VarPtr(lpIconOvr)
            End If
            If (lpIconOvr > 15) Or (lpIconOvr < 0) Then
                'Overlay icons are a mess. On Win7 there's a bunch in root that return 16, which is invalid
                'and will cause a crash later one, and doesn't show anything. Shares never get shown so I'm
                'going to manually set those
                lpIconOvr = -1
                If (lAtr And SFGAO_SHARE) = SFGAO_SHARE Then
                    lpIconOvr = 1
                End If
                If (lAtr And SFGAO_LINK) = SFGAO_LINK Then
                    lpIconOvr = 2
                End If
            End If
            EnsureOverlay lpIconOvr

Page 3 of 6 FirstFirst 123456 LastLast

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
  •  



Click Here to Expand Forum to Full Width