KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

TREEVIEW capabilities in Kixforms Classic

 
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting
View previous topic :: View next topic  

As the forum seems almost deserted these days, is there anyone out there still developing Classic Kixforms ?
Yes
83%
 83%  [ 5 ]
No
16%
 16%  [ 1 ]
Total Votes : 6

Author Message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Fri Aug 07, 2009 3:29 pm    Post subject: TREEVIEW capabilities in Kixforms Classic Reply with quote

Before I totally lose the plot, is there anyone who knows enough about classic Treeview to identify why in the following tester A) won't even add Child Nodes when it works fine in the Main App, and B) the main reason for the post, HOW DO YOU PASS A SELECTED NODE + CHOSEN CHILD NODE as a new NODE reference for Recursion...
I have tried more combination of indices than I can describe and all return null. Even tried the .Find as illustrated here but Nul.
AHHHHHHHhhhhhhhhhhhhhhhhhhh
Is there a way to use the FullPath text which is always right to convert back to a node reference ??

NB: It needs to remain 'classic' kixforms, NOT .net for portability.

Code:

break on
cls ;show console
$System = CreateObject("Kixtart.System")
$fso=createobject("scripting.filesystemobject")
$=SETOPTION("NoMacrosInStrings","ON")
$=SETOPTION("NoVarsInStrings","ON")
Dim $KX,$KY
Global $Root
$Root=EXPANDENVIRONMENTVARS ("%userprofile%")+'\'

;Form Size
$KX=600
$KY=475
$TestForm = $System.Form()
$TestForm.MaximizeBox = "False"
$TestForm.Text = "Classic Treeview Test"
$TestForm.TopMost = "True"
$TestForm.Width = $KX
$TestForm.Height = $KY
$TestForm.FormBorderStyle = 5
$TestForm.Center()

$TreeView = $TestForm.Controls.TreeView()
$TreeView.Dock = 5
$TreeView.ImageList = $System.BuiltinImageList()
$TreeView.ImageIndex = 45
$TreeView.LabelEdit = false
$TreeView.SelectedImageIndex = 46
$TreeView.sorted = True
$TreeView.Cursor = 16
$TreeView.ToolTipText ="Right Click to SELECT BRANCH"
$TreeView.CtxtMenu = $System.ContextMenu()
$TreeView.OnMouseDown = "ETV_MouseDown()"

$TreeView.CtxtMenu.SelectAll = $TreeView.CtxtMenu.MenuItems.Add("Select Branch")
$TreeView.CtxtMenu.SelectAll.Visible = 1
$TreeView.CtxtMenu.SelectAll.Enabled = true
$TreeView.CtxtMenu.SelectAll.OnClick = "Recursion($TreeView.SelectedNode.fullpath)"

$=$TreeView.Nodes.Add('My Documents')

$TestForm.Show

While $TestForm.Visible
 $=Execute($TestForm.DoEvents())
Loop
exit
;------------------------------------------------------------------------------
Function Recursion($Xnode)   ;$Xnode is passed as current Selected Node
  Dim $i,$C
  ;Now work way through child folders
  $Fldr = $fso.GetFolder($XNode.fullpath)
  For Each $SF In $Fldr.SubFolders
   $C=$fso.GetFolder($SF)
   $i = $XNode.Find($C.Name, 'true' ) ; This is returning Nothing ??
   ? $Xnode.text+' SF='+$SF+' i='+$i+'  C='+$C.text
   /*
   Do Stuff
   Cant find a means of adding a found sub node to the current node to drill down through folders.
   */
   ;$=Recursion(>>$Xnode+$C.Name.NODE<<)
  next
  $Recursion=''
  Exit $Recursion
EndFunction
;------------------------------------------------------------------------------
Function DirTree($Path,$XNode)
cls

Dim $Fldr,$SF,$Y,$T,$i,$L,$C,$IDX
$TreeView.SelectedNode = $XNode
;Iterate through subfolders
$Fldr = $fso.GetFolder($Root+$Path)
For Each $SF In $Fldr.SubFolders
  $T=right($SF,-len($Root+$Path))
? $Root+$Path+' + '+$T+' | Add to Node:'+$Xnode.Fullpath
  ; The following works in my full app but here in this tester I get IDispatch error ??
  $XNode.Nodes.Add($T)
  $XNode.Expand
Next

EndFunction
;------------------------------------------------------------------------------
Function ETV_MouseDown()
 Dim $Node
 $Node = $TreeView.GetNodeAt($TreeView.MouseX, $TreeView.MouseY)
 If Not $Node
  Return
 Endif
 $TreeView.SelectedNode = $Node

 If ($TreeView.MouseButton & 2) ; right-click
  $= $TreeView.CtxtMenu.Show($TreeView,$TreeView.MouseX,$TreeView.MouseY)
 Endif

 If Not ($TreeView.MouseButton & 2) ; Not right-click
   $=DirTree($Node.Fullpath+'\',$Node)
 EndIf
EndFunction
;------------------------------------------------------------------------------


________
LAMBORGHINI 350GT SPECIFICATIONS


Last edited by MACE1 on Fri Feb 18, 2011 5:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Aug 11, 2009 2:03 pm    Post subject: Cant be done, can only identify child at creation time... so Reply with quote

Have to do the recursion within DirTree function not as a separate function...
Code:

$TreeView.CtxtMenu.SelectAll.OnClick = "DirTree($Root+$TreeView.SelectedNode.fullpath+'\',$TreeView.SelectedNode,99)" ;Allowed for 99 levels

$=$TreeView.Nodes.Add('My Documents')

$TestForm.Show

While $TestForm.Visible
 $=Execute($TestForm.DoEvents())
Loop
exit
;------------------------------------------------------------------------------
Function DirTree($Path,$XNode,Optional $R)
Dim $Fldr,$SF,$T
;Iterate through subfolders
$Fldr = $fso.GetFolder(left($Path,-1))
For Each $SF In $Fldr.SubFolders
 $T=right($SF,-len($Path))
 $Child=$XNode.Nodes.Add($T)
 $=$XNode.Expand
? $path+$Child.text+'\'
 If $R>0
  $=DirTree($path+$Child.text+'\',$Child,$R-1)
 Endif
Next
EndFunction
;------------------------------------------------------------------------------
Function ETV_MouseDown()
 Dim $Node,$X
 $Node = $TreeView.GetNodeAt($TreeView.MouseX, $TreeView.MouseY)
 If Not $Node
  Return
 Endif
 $TreeView.SelectedNode = $Node

 If Not ($TreeView.MouseButton & 2) ; Not right-click
   $=DirTree($Root+$Node.Fullpath+'\',$Node)
   exit
 EndIf

 If ($TreeView.MouseButton & 2) ; right-click
  $= $TreeView.CtxtMenu.Show($TreeView,$TreeView.MouseX,$TreeView.MouseY)
 Endif
EndFunction
;------------------------------------------------------------------------------



Painful to get there but at least the code is quick and does not need lots of scanning of node indexes and text names !!
________
Mortgage life insurance forums
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group