www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DFL TreeView with Icons

reply Robert <no spam.com> writes:
Hello all,

I was wondering if anyone had any experience with the DFL GUI library and  
might be able to point out what I'm doing wrong. I am a bit of a beginner  
with D.

I am using the DFL release 0.9.8 with DMD 1.030 which I have found works  
really well.

I have taken the example provided with the DFL release "dirlistview.d" and  
adpated it to work with a TreeView instead of a ListView. However when I  
run this code, the icons do not appear as expected. The first node shows  
no icon, and the second node in the tree shows its icon only when selected.

Below is the example code. Can anyone see what I am doing wrong or have  
any experience with this?

Thanks in advance!

// Compile with:
// dfl -gui treedemo.d

import dfl.all;

class TreeDemo: dfl.form.Form {

    TreeView tree;

    this() {
       text = "Tree Demo";
       clientSize = Size(250, 200);
       dockPadding.all = 5;

       tree = new TreeView();
       tree.dock = DockStyle.FILL;
       tree.parent = this;
       tree.itemHeight = 32;

       load ~= &form_load;
    }

     private void form_load(Object sender, EventArgs ea) {
       ImageList imageList = new ImageList();
       imageList.imageSize = Size(32, 32);
       imageList.colorDepth = ColorDepth.DEPTH_32BIT;

       Resources ires = new Resources("shell32.dll");

       imageList.images.add(ires.getIcon(3, true));
       imageList.images.add(ires.getIcon(4, true));

       tree.imageList = imageList;

       TreeNode root = new TreeNode();
       root.text = "Hello";
       tree.nodes.add(root);
       root.imageIndex = 3;

       TreeNode next = new TreeNode();
       next.text = "World";
       tree.nodes[0].nodes.add(next);
       next.imageIndex = 4;
     }
}

int main()
{
    int result = 0;
    try {
       Application.enableVisualStyles();
       Application.run(new TreeDemo());
    } catch(Object o) {
       msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK,  
MsgBoxIcon.ERROR);
       result = 1;
    }
    return result;
}


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 15 2009
parent SpeeDy <speedy nospam.com> writes:
Robert Wrote:
 run this code, the icons do not appear as expected. The first node shows  
 no icon> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Not sure whether you have compiled your resource (.ico) with Digital Mars' rcc,then compile the D program with that compiled *.res. Later. SpeeDy
Oct 15 2009