Shoutbox

TreeView - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: TreeView (/showthread.php?tid=91566)

TreeView by mathieumg on 07-19-2009 at 11:19 PM

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.


RE: TreeView by matty on 07-20-2009 at 12:38 PM

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.


RE: TreeView by mathieumg on 07-20-2009 at 05:21 PM

Thanks, I'll take a look into that :)


RE: TreeView by mathieumg on 07-21-2009 at 02:52 AM

I got it to work :)

However, I still need help with some API functions :o

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!


RE: TreeView by mathieumg on 07-26-2009 at 01:48 PM

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


RE: TreeView by matty on 07-26-2009 at 02:36 PM

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(X) and it will tell you the size of the structure.
RE: TreeView by mathieumg on 07-26-2009 at 03:50 PM

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;
    }
}


Thanks
RE: TreeView by matty on 07-26-2009 at 04:25 PM

Javascript 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:
Javascript 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;
    }
}


RE: TreeView by mathieumg on 07-26-2009 at 09:27 PM

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);


RE: TreeView by matty on 07-27-2009 at 12:31 PM

No problem!

Glad you got it working!