Results 1 to 3 of 3

Thread: TreeView Icons

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    9

    Question

    Hi All:

    I'm having a royal fit with icons used with the TreeView control and I'm hoping SOMEONE out there can help me!

    Here's the situation: I've got a TreeView and have associated it to an ImageList. In the ImageList I have loaded the various icons I wish to use along with meaningful names so that each icon may be referenced by its name. If I start by loading the icons from those provided with VB, the ImageList defaults to a 32x32 size and will NOT let me change it. And, when used, the icons on the TreeView are HUGE. Dragging an node, though, uses the associated icon for the node, which looks good.

    The spacing, though, when using 32x32 icons is just not acceptable in the TreeView. So, I created another ImageList, set its size to 16x16, and loaded in the same icons. The size stayed put at 16x16, and the icons actually resize themselves rather intelligently on the TreeView. But now, when I drag around a node, the icon displayed is back to 32x32, which wouldn't be all that bad except for the fact that the 32x32 icon is created from the 16x16 image, so it looks like crap.

    My next thought was to start with 16x16 icons, so I tried my hand at creating icons similar to what the 32x32 versions presented, just in a 16x16 size. These load nicely onto the TreeView, but, once again, the image presented when dragging a node is an interpolated 32x32 image which is quite blocky and ugly as anything.

    I am using the CreateDragImage method of the TreeView control to assign the image from the node to the TreeView's DragIcon. What am I doing wrong? Can anyone point me in the right direction to get this thing to use icons at the size I want without the horrible blockiness I'm seeing when I drag nodes?

    Thanks in advance!

    Jon
    Jon Westcot, RLISYS

  2. #2
    Guest
    I had a go at this today by coincidence!

    what I did was set 16 x 16 and then clicked APPLY, then add the icons.

    they looked fine on the treeview.

    The thing to keep in mind is that proper icons have "pages", that is, it skips to a different bitmap representation if the icon is in the title bar of a window, compared to if it is on the desktop as a fullsize icon.

    ps you cant mix 16x16 and 32x32 icons in a single imagelist.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    9
    Thanks, Wossname, for your reply.

    I created an ImageList that was pre-set to 16x16 and added in my icons. And yes, the images displayed on the TreeView looked just fine . . . until I started dragging them about! Then, they flopped over to being 32x32 images that were created by scaling up the 16x16 images. In other words, they were ugly and blocky!

    So, not wanting to waste more time on this than necessary (and why is it that the little niggling points, which comprise maybe 3% of an application, take 97% of the total development time to get right? <g>), I created a second ImageList, pre-set to 32x32, and populated it with the same exact icons and even assigned them the same exact Key names. Then, when it came time to drag around the icon, instead of using the CreateDragIcon command (or whatever it is; my brain isn't firing well at the moment), I assign the icon to the associated Picture from the other ImageList. Voila! The dragged icons look nice and clean, the miniature icons in the TreeView are acceptable, and I deemed it good.

    Jon Westcot, RLISYS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width