| TreeView | 
| Author: | Message: | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  TreeView What I understand from my search is that the only way there is to interact with a TreeView control at the moment is to use the Win32 API? Is that correct? How would I go about say, adding a few options to a TreeView and detecting when there is a click done on one item (along with its ID/index)? (Those are the only things I would need to do with the control)
 Is there a script in the DB that already does that? I could take a look at it since I'm self-taught.
 
 Thanks for the help.
 Official MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-19-2009 11:19 PM |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 | | RE: TreeView You need to subclass the window and fill the TVITEM structure normally from NMHDR. I have some code at home I can post if no one posts anything in the next while.
 The attachment is taken from the Log Manager script by Matti.
 
  Attachment: _treeView.zip (2.32 KB) This file has been downloaded 222 time(s).
 
 This post was edited on 07-20-2009 at 12:40 PM by matty.
 | 
 | 
| 07-20-2009 12:38 PM |  | 
|  | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  RE: TreeView Thanks, I'll take a look into that  Official MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-20-2009 05:21 PM |  | 
|  | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  RE: TreeView I got it to work    
However, I still need help with some API functions    
In my code I am at the point where I know when TVN_SELCHANGED  has happened. 
 
I want to go further and get its NMTREEVIEW  structure and from it, get the the TVITEM  both from itemOld and itemNew. Then, I want to get the handle of both these TVITEM structures and I should have everything I need to do what I intend to do.
 
Thanks for helping me!Official MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-21-2009 02:52 AM |  | 
|  | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  RE: TreeView Do you know where I could find help for STRUCTS in JScript? It's kind of hard to ask help about this on other forums when it has to use the Plus! Interop and Databloc objects.
 Thanks
 Official MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-26-2009 01:48 PM |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 | | RE: TreeView There aren't any documented structures unless they are used in scripts (in which you need to then search the code). 
Really your only option is to calculate the size itself.
Data types : Size Byte : 1
Integer : 2
Long : 4
String : 4
Variant : 8
 
If you have Visual Basic 6 installed you can cheat and declare a variable as a specific structure then do MsgBox Len   and it will tell you the size of the structure. | 
 | 
| 07-26-2009 02:36 PM |  | 
|  | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  RE: TreeView I would need some help to get started with the NMTREEVIEW I talked about in my post above, here is what I have: JScript code:function OnWndSettingsEvent_MessageNotification(PlusWnd, Message, wParam, lParam) {
 switch (Message) {
 case WM_NOTIFY:
 var NMHDR = Interop.Allocate(12);
 Interop.Call('kernel32', 'RtlMoveMemory', NMHDR.DataPtr, lParam, 12);
 if (NMHDR.ReadDWORD(0) == PlusWnd.GetControlHandle("TrvSettingGroups")) {
 switch(NMHDR.ReadDWORD(8)) {
 case TVN_SELCHANGEDW: case TVN_SELCHANGEDA:
 //TreeView selection changed
 
 Debug.Trace("TreeView selection changed:");
 
 //Now I want to get the NMTREEVIEW structure and from it, get the the TVITEM both from itemOld and itemNew. Then, I want to get the handle of both these TVITEM structures
 
 break;
 }
 }
 NMHDR.Size = 0;
 break;
 }
 }
 
 
ThanksOfficial MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-26-2009 03:50 PM |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 | | RE: TreeView js code:function OnWndSettingsEvent_MessageNotification(PlusWnd, Message, wParam, lParam) {
 switch (Message) {
 case WM_NOTIFY:
 var NMHDR = Interop.Allocate(12);
 Interop.Call('kernel32', 'RtlMoveMemory', NMHDR.DataPtr, lParam, 12);
 if (NMHDR.ReadDWORD(0) == PlusWnd.GetControlHandle("TrvSettingGroups")) {
 switch(NMHDR.ReadDWORD(8)) {
 case TVN_SELCHANGEDW: case TVN_SELCHANGEDA:
 var NMTREEVIEW = Interop.Allocate(104);
 Interop.Call('kernel32', 'RtlMoveMemory', NMTREEVIEW.DataPtr, lParam, 104);
 /*
 NMTREEVIEW
 NMHDR : 0-12
 Action : 12-16
 TVITEM (itemOld) : 16-56
 TVITEM (itemNew) : 56-96
 POINT : 96-104
 */
 break;
 }
 }
 NMHDR.Size = 0;
 break;
 }
 }
 
 
However in theory you could just do this:
 js code:function OnWndSettingsEvent_MessageNotification(PlusWnd, Message, wParam, lParam) {
 switch (Message) {
 case WM_NOTIFY:
 var NMTREEVIEW = Interop.Allocate(104);
 Interop.Call('kernel32', 'RtlMoveMemory', NMTREEVIEW.DataPtr, lParam, 104);
 if (NMTREEVIEW.ReadDWORD(0) == PlusWnd.GetControlHandle("TrvSettingGroups")) {
 switch(NMTREEVIEW.ReadDWORD(8)) {
 case TVN_SELCHANGEDW: case TVN_SELCHANGEDA:
 /*
 NMTREEVIEW
 NMHDR : 0-12
 Action : 12-16
 TVITEM (itemOld) : 16-56
 TVITEM (itemNew) : 56-96
 POINT : 96-104
 */
 break;
 }
 }
 NMTREEVIEW.Size = 0;
 break;
 }
 }
 
This post was edited on 07-27-2009 at 12:32 PM by matty.
 | 
 | 
| 07-26-2009 04:25 PM |  | 
|  | 
| mathieumg Full Member
 
    
 
 Posts: 181
 Reputation: 2
 36 /
  /  Joined: May 2004
 
 | | O.P.  RE: TreeView After that, do I do JScript code:var itemOld = NMTREEVIEW.ReadDWORD(16);
 var itemNew = NMTREEVIEW.ReadDWORD(56);
 
 
And then some code to read the handle for both structures? (I tried itemOld.ReadDWORD(4) to no avail)
 
I presume that is not exactly the right way to do, that is why I need help with this    
Thank you again for helping me, I will certainly learn a lot out of this    
Edit:
 
I wasn't that far after all    I got it and I also started to understand some code in the treeview class    
Thanks a lot for the help matty!    
Here is my code:
 JScript code:var hOldItem = NMTREEVIEW.ReadDWORD(20);
 var hNewItem = NMTREEVIEW.ReadDWORD(60);
 
This post was edited on 07-26-2009 at 10:31 PM by mathieumg.
 Official MessengerPlus! Live French Translator 
Official StuffPlug 3 French Translator
  | 
 | 
| 07-26-2009 09:27 PM |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 | | RE: TreeView No problem!
 Glad you got it working!
 | 
 | 
| 07-27-2009 12:31 PM |  | 
|  | 
|  |