Shoutbox

[?] Tree-view controls and item images - 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: [?] Tree-view controls and item images (/showthread.php?tid=94482)

[?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 02:53 PM

I'm working on something that makes handling tree-view controls a little easier. However, I don't see how to add images to an item.


RE: [?] Tree-view controls and item images by Matti on 04-29-2010 at 05:25 PM

Matty and I made a tree-view class some time ago. The code isn't very beautiful and properly could use a rewrite, but it should be readable enough to understand how it works.
Basically, to add an item you send a TVM_INSERTITEM message with a TVINSERTSTRUCT. To change an item you send a TVM_SETITEM message with a TVITEM structure.


RE: [?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 05:29 PM

I've read your class hours ago, and I am afraid.. well.. ya know :p If I'd understood the image-handling thingy, I wouldn't have posted :P


RE: [?] Tree-view controls and item images by matty on 04-29-2010 at 05:33 PM

Wow that is SO ugly... I can't believe we, at one point, wrote that...


RE: [?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 05:35 PM

Yeah.. Can't read it :P @Matti: think you need to check encoding etc. Or just pack it to a ZIP file :P


RE: [?] Tree-view controls and item images by matty on 04-29-2010 at 05:36 PM

quote:
Originally posted by SmokingCookie
Yeah.. Can't read it :P @Matti: think you need to check encoding etc. Or just pack it to a ZIP file :P
Save the file as a JS file and open it in Notepad++. It is a unicode file.
RE: [?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 05:40 PM

Well, I've got the file here as well, as Countdown Live uses it, and I use CDL :P

But that doesn't really solve my problem :P


RE: [?] Tree-view controls and item images by Matti on 04-29-2010 at 05:50 PM

Then what is the problem you're having? Do you need to add a new image to the tree's image list or something? Or do you have trouble finding what arguments to pass to those functions?


RE: [?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 05:52 PM

I've got absolutely no idea how to add an item with an image. So that's pretty much both.


RE: [?] Tree-view controls and item images by Matti on 04-29-2010 at 06:12 PM

Well, first of all you'll need to put some images in the tree view's image list. In order to prevent Plus! from messing up the image indexes, I always prefix the image ID with the image position.

XML code:
<Control xsi:type="TreeViewControl" Id="MyTree">
    <Position Left="10" Top="10" Width="100" Height="150" />
    <Images>
        <NormalIcons>
            <Image Id="01-folder">
                <Name>icon-folder</Name>
            </Image>
            <Image Id="02-file">
                <Name>icon-file</Name>
            </Image>
        </NormalIcons>
    </Images>
</Control>

Now to add an item, you can use TreeView::addItem.
Javascript code:
var tree = new TreeView(PlusWnd, "MyTree");
var parentNode = tree.addItem("My folder", 0, 0);
var childNode = tree.addItem("My file", parentNode, 1);

This will add a root node with a child node to the tree. The root node will have a folder icon and the child node will have a file icon (assuming that you have those images in your script).
RE: [?] Tree-view controls and item images by SmokingCookie on 04-29-2010 at 06:50 PM

Got it :D
Thanks :d