DFL TreeView with Icons

Robert no at spam.com
Thu Oct 15 08:50:08 PDT 2009


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/


More information about the Digitalmars-d-learn mailing list