Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TreeView control Conquered, I think...
Message
De
08/09/1997 08:51:10
 
 
À
08/09/1997 06:12:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00048920
Message ID:
00048930
Vues:
22
I suggest you to create an article/FAQ in the Knowledge Base with this sample. If you wanna do so, just click on the dice icon on the left and proceed with it.

Vlad

>I was having a lot of trouble with the Treeview control, until Nick gave me that all important hint.
>The idea was to replicate an Explorer type interface using the control. For this I needed an function
>that could read and replicate an entire Treeline onto another node. Typically the result of an
>drag & drop operation. The function I came up with pleased me so much I decided to show to you all,
>so that you may rip it apart. Have fun
>
>*-----------------------------
>*-- Code for pNodeMove Method
>*-----------------------------
>*poRefTrv: Reference to the Treeview object the node is dropped on
>*poNode: Reference to the Treeview object the node is dropped on
>*poTargetNode: : The node is dropped on, usually the result of an HitTest method
>*-----------------------------
>LPARAMETER poRefTrv, poNode, poTargetNode
>IF TYPE( "poRefTrv") # "O" OR ISNULL( poRefTrv)
> RETURN .F.
>ENDIF
>IF TYPE( "poNode") # "O" OR ISNULL( poNode)
> RETURN .F.
>ENDIF
>IF TYPE( "poTargetNode") # "O" OR ISNULL( poTargetNode)
> RETURN .F.
>ENDIF
>
>LOCAL llReturn, lloRef, lnCount ;
> , laNode, lnAryCnt
>
>IF ISNULL( poNode)
> RETURN .F.
>ENDIF
>
>DIME laNode( 1, 4) && Parent key, node key, text, image
>lnAryCnt = 0
>
>loRef = poNode
>lnAryCnt = lnAryCnt + 1
>DIME laNode( lnAryCnt, 4)
>laNode( lnAryCnt, 1) = poTargetNode.KEY
>laNode( lnAryCnt, 2) = loRef.KEY
>laNode( lnAryCnt, 3) = loRef.TEXT
>laNode( lnAryCnt, 4) = loRef.IMAGE
>
>oRoot = poRefTrv
>lnCount = 1
>DO WHILE .T.
>
> loRef = oRoot.Nodes( laNode( lnCount, 2) ).CHILD
> DO WHILE .T.
> IF ISNULL( loRef)
> EXIT
> ELSE
> lnAryCnt = lnAryCnt + 1
> DIME laNode( lnAryCnt, 4)
> laNode( lnAryCnt, 1) = loRef.PARENT.KEY
> laNode( lnAryCnt, 2) = loRef.KEY
> laNode( lnAryCnt, 3) = loRef.TEXT
> laNode( lnAryCnt, 4) = loRef.IMAGE
> ENDIF
> loRef = loRef.NEXT
> ENDDO
>
> *-- Getting the Next variable in the Tree heiarchy
> lnCount = lnCount + 1
> IF lnCount > lnAryCnt
> EXIT
> ENDIF
>ENDDO
>lnCount = 0
>lnMaxCount = 0
>
>oRoot.Nodes.REMOVE( laNode( 1, 2) )
>FOR lnCount = 1 TO ALEN( laNode, 1)
> IF !ISNULL( oRoot.ImageList)
> loRef = oRoot.Nodes.ADD( laNode( lnCount, 1), 4, laNode( lnCount, 2), laNode( lnCount, 3), laNode( lnCount, 4))
> ELSE
> loRef = oRoot.Nodes.ADD( laNode( lnCount, 1), 4, laNode( lnCount, 2), laNode( lnCount, 3))
> ENDIF
> loRef.EnsureVisible
>ENDFOR
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform