[Help needed] ActiveX TreeView Control

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

mattisse
Posts: 65
Joined: Fri Feb 02, 2007 8:07 am
Contact:

[Help needed] ActiveX TreeView Control

Post by mattisse »

Hello scripters,

has anyone of you ever used a TreeView ActiveX object in a MM script?
I'ven been trying to display a hierarchical tree on a simple form. The problem however is that the items don't show up as nested nodes as intended. All I got was a flat list.

Is it possible at all to use such an object within MM? Help is very much appreciated.

Here is the sample code I used:

Code: Select all

Dim nodX

Sub OnStartup

Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 0, 0)
   Mnu.Caption = "Open Form..."     
   Mnu.UseScript = Script.ScriptPath
   Mnu.OnClickFunc = "ShowIt"
  

End Sub

Sub ShowIt( Itm)
  Set UI = SDB.UI

  ' Create the window to be shown
  Set Form = UI.NewForm
  Form.Common.SetRect 100, 100, 500, 400
  Form.Caption = "MyForm"
  Form.StayOnTop = True
  
  Set tvcExample = UI.NewActiveX (Form, "COMCTL.TreeCtrl")

 

  ' Set Treeview control properties.
  tvcExample.Common.Width = 200
  tvcExample.Common.Height = 400
  tvcExample.Interf.LineStyle = tvwRootLines  ' Linestyle 1
  ' Add Node objects
  ' First node with 'Root1' as text.
  Set nodX = tvcExample.Interf.Nodes.Add(, , "r1", "Root1")
  ' Second node on root with 'Root2' as text
  Set nodX = tvcExample.Interf.Nodes.Add(, , "r2", "Root2")
  ' This next node is a child of Node 1 ("Root").
  Set nodX = tvcExample.Interf.Nodes.Add("r1", tvwChild, "child1", "Child")
            
  Form.Common.Visible = True                
  SDB.Objects("Sample Form") = Form

        
End Sub
Regards,
mattisse
RedX
Posts: 366
Joined: Wed Dec 27, 2006 10:32 am
Location: Germany
Contact:

Post by RedX »

Copied the code into auto folder and all i got was:

Image
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Try something more like this...

Code: Select all

  ' First node with 'Root1' as text.
  Set nodeR1 = tvcExample.Interf.Nodes.Add(, , "r1", "Root1")
  ' Second node on root with 'Root2' as text
  Set nodeR2 = tvcExample.Interf.Nodes.Add(nodeR1,tvwChild, "r2", "Root2")
I've not tried it, but looking at a few online examples it seems the first argument should be the parent node.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
mattisse
Posts: 65
Joined: Fri Feb 02, 2007 8:07 am
Contact:

Post by mattisse »

@RedX
That Error message probably means that the MS Common Controls library isn't installed properly on your computer or that it isn't up to date.
I think people reported similar errors with Steegy's Library Panes script.

@trixmoto
I tried your variation, but unfortunately it didn't make any difference. The first argument in my example is the key of the parent node which usually works as well (at least it does in Access).

Thank you both for looking into this.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Contact:

Post by Steegy »

@RedX
That Error message probably means that the MS Common Controls library isn't installed properly on your computer or that it isn't up to date.
I think people reported similar errors with Steegy's Library Panes script.
No, the reason is that this control can only be used if you have a licence for it. Only developers (e.g. using Miscosoft Visual products) can have such a licence. So "legally" it is not very handy to use this control in public scripts. However, you can easily "h.ck" this (but don't tell aloud on this forum, as you will get complaints from a specific forum member... :o). Just search the internet for a license code for your activex control (it's a registry key you need). To do everything clean, you can easily install the control and register the license in a script installer, or in the script itself (yeah, some scripts do this without you knowing it :))
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Post Reply