FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using icons in TreeView

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
gigi



Joined: 20 May 2007
Posts: 1

PostPosted: Sun May 20, 2007 4:12 am    Post subject: Using icons in TreeView Reply with quote

Hi all.
I'm new here and I still do not have great experience with DFL, so it can be that my following question is simply ""stupid"" ...
I'm using DFL for a project and I was trying to use the teeview component. It works ok but I was not able to find a way to add icons to tree nodes (and maybe a method to specify a different icon per node level).

Is this supposed to be implemented or not?
If not, is there a simple way to do that without changing the DFL internals (I do not know, by simply creating a "child" treeview and overrinding some methods?)

Thanks very much!
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed May 23, 2007 4:51 am    Post subject: Re: Using icons in TreeView Reply with quote

It's not supported yet, sorry. It's planned to be implemented soon.

It involves image lists. Each TreeNode has a handle (HTREEITEM) with which you can attempt to do it yourself if you can't wait.

- Chris
Back to top
View user's profile Send private message
GencoreOperative



Joined: 04 Oct 2009
Posts: 3

PostPosted: Tue Oct 13, 2009 8:54 am    Post subject: Reply with quote

Hello,

Related to the original post, I have followed the dirlistview.d example shipped with 0.9.8 and have adapted it for the TreeView control. My objective is to display an icon against each item in the TreeView.

The example I have included below appears to display some strange behaviour which I am unable to work out. The first node in the tree does not display an icon. The child node of the first, displays an icon only when selected.

Does anyone have an idea what I am doing wrong in this code?

Thanks!

Code:
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;
}
Back to top
View user's profile Send private message
GencoreOperative



Joined: 04 Oct 2009
Posts: 3

PostPosted: Mon Nov 16, 2009 5:26 am    Post subject: Reply with quote

I've posted my learning so far with D to my site: http://sites.google.com/site/learningdthoughts/home. I'm hoping that will help people with similar problems.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group