Results 1 to 40 of 228

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

Hybrid View

  1. #1
    Fanatic Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    545

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

    I fixed the RootHasCheckbox problem in ucWndProc -> TVN_ITEMCHANGINGW

    Before:

    Code:
                Case TVN_ITEMCHANGINGW
                    If (bFilling = False) And (g_fDeleting = False) And (mAutocheck = True) Then
                       .....
                    End If
    After:

    Code:
    Case TVN_ITEMCHANGINGW
       If (bFilling = False) And (g_fDeleting = False) And (mAutocheck = True) Then
          .....
       ElseIf (bFilling = False) And (g_fDeleting = False) Then
             'MITH
            Call CopyMemory(nmtvic, ByVal lParam, LenB(nmtvic))
            tvix.Mask = TVIF_STATEEX
            tvix.hItem = nmtvic.hItem
            Call SendMessage(hTVDW, TVM_GETITEM, 0, tvix)
            If (nmtvic.hItem = m_hRoot) And (mRootHasCheckbox = False) Then
                lReturn = 1
                bHandled = True
                Exit Sub
            End If
            idx = GetTVItemlParam(hTVD, nmtvic.hItem)
            tNew = TVEntries(idx)
            If (tNew.bFolder = True And mShowOnlyFileCheckbox = True And mShowFiles = True) Then
                lReturn = 1
                bHandled = True
                Exit Sub
            End If
        End If
    New code for property ShowOnlyFileCheckbox:

    Code:
    Private mShowOnlyFileCheckbox As Boolean
    Private Const mShowOnlyFileCheckbox_def As Boolean = False
    
    Public Property Get ShowOnlyFileCheckbox() As Boolean: ShowOnlyFileCheckbox = mShowOnlyFileCheckbox: End Property
    Public Property Let ShowOnlyFileCheckbox(bVal As Boolean)
       mShowOnlyFileCheckbox = bVal
    End Property
    
    Private Sub UserControl_ReadProperties(propBag As PropertyBag)
    mShowOnlyFileCheckbox = propBag.ReadProperty("ShowOnlyFileCheckbox", mShowOnlyFileCheckbox_def)
    End Sub
    Private Sub UserControl_WriteProperties(propBag As PropertyBag)
    propBag.WriteProperty "ShowOnlyFileCheckbox", mShowOnlyFileCheckbox, mShowOnlyFileCheckbox_def
    End Sub
    Private Sub UserControl_InitProperties()
    mShowOnlyFileCheckbox = mShowOnlyFileCheckbox_def
    End Sub
    Code:
    Private Sub TVExpandFolder(lParam As Long, hitemParent As Long)
            .....
    	If bFav Or (bFolder = True And mShowOnlyFileCheckbox = True And mShowFiles = True) Then 'Mith
    	    TreeView_SetCheckStateEx hTVD, hitemPrev, 0
    	Else
    	    If TreeView_GetCheckState(hTVD, hitemParent) = 2 Then
    	       If mAutocheck = True Then
    	        TreeView_SetCheckState hTVD, hitemPrev, 1
    	       End If
    	    End If
    	End If
    	.....
    End Sub

  2. #2
    Fanatic Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    545

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

    Quote Originally Posted by Mith View Post
    I fixed the RootHasCheckbox problem in ucWndProc -> TVN_ITEMCHANGINGW

    Before:

    Code:
                Case TVN_ITEMCHANGINGW
                    If (bFilling = False) And (g_fDeleting = False) And (mAutocheck = True) Then
                       .....
                    End If
    After:

    Code:
    Case TVN_ITEMCHANGINGW
       If (bFilling = False) And (g_fDeleting = False) And (mAutocheck = True) Then
          .....
       ElseIf (bFilling = False) And (g_fDeleting = False) Then
             'MITH
            Call CopyMemory(nmtvic, ByVal lParam, LenB(nmtvic))
            tvix.Mask = TVIF_STATEEX
            tvix.hItem = nmtvic.hItem
            Call SendMessage(hTVDW, TVM_GETITEM, 0, tvix)
            If (nmtvic.hItem = m_hRoot) And (mRootHasCheckbox = False) Then
                lReturn = 1
                bHandled = True
                Exit Sub
            End If
            idx = GetTVItemlParam(hTVD, nmtvic.hItem)
            tNew = TVEntries(idx)
            If (tNew.bFolder = True And mShowOnlyFileCheckbox = True And mShowFiles = True) Then
                lReturn = 1
                bHandled = True
                Exit Sub
            End If
        End If
    I found a bug in my code changes. I copied and paste to much of your code

    The correct changes are:

    Code:
    Case TVN_ITEMCHANGINGW
       If (bFilling = False) And (g_fDeleting = False) And (mAutocheck = True) Then
          .....
       ElseIf (bFilling = False) And (g_fDeleting = False) Then
             'MITH
            Call CopyMemory(nmtvic, ByVal lParam, LenB(nmtvic))
            idx = GetTVItemlParam(hTVD, nmtvic.hItem)
            tNew = TVEntries(idx)
            If (tNew.bFolder = True And mShowOnlyFileCheckbox = True And mShowFiles = True) Then
                lReturn = 1
                bHandled = True
                Exit Sub
            End If
        End If

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