Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using TreeView control

Posted on 1998-12-28
1
Medium Priority
?
273 Views
Last Modified: 2013-12-03
If I use a TreeView control the bitmaps won't load. Next is the code I use to achieve on another:

Header file:

#include <commctrl.h>   // includes the common control header

#define MAXTREEVIEWS         32
#define ID_TREEVIEW          1000

#define BMP_NONE             0
#define BMP_FOLDER           1
#define BMP_FOLDER_SELECTED  2

#define NUM_BITMAPS          2
#define BMP_HEIGHT           16
#define BMP_WIDTH            16

Following is the code-fragment that loads the bitmaps:

  // Initialize the tree view window.
  // First create the image list you will need.
  hIml = ImageList_Create(BMP_WIDTH       // bitmap width
                         ,BMP_HEIGHT      // bitmap height
                         ,0               // creation flags
                         ,NUM_BITMAPS     // number of images
                         ,0               // amount this list can grow
                         );

  // Load the bitmaps and add them to the image list.
  hBmp = LoadBitmap(hInstance
                   ,MAKEINTRESOURCE(BMP_FOLDER)
                   );
  if (hBmp == NULL){
    MessageBox(hWndParent
              ,"Bitmap not loaded!!!"
              ,"createTreeView()..."
              ,MB_OK
              );
  }
   
  idxFolder = ImageList_Add(hIml        // handle to imagelist
                           ,hBmp        // handle of bitmap to add
                           ,NULL        // handle of bitmap mask
                           );
  hBmp = LoadBitmap(hInstance
                   ,MAKEINTRESOURCE(BMP_FOLDER_SELECTED)
                   );
  idxFolderSelected = ImageList_Add(hIml
                                   ,hBmp
                                   ,NULL
                                   );

Following is the content of the resource file:

#include "vdgtreeview.h"


BMP_FOLDER BITMAP DISCARDABLE "bmp_folder.bmp"
BMP_FOLDER_SELECTED BITMAP DISCARDABLE "bmp_folder_selected.bmp"

Can anybody tell me what's wrong?

Thanx
Henk
0
Comment
Question by:hge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
jmayfield earned 200 total points
ID: 1417759
I can't believe that no one has given you an answer. We can work this one out together until you get it working. I have done what you are doing many times.

You might want to change the following params in your:
ImageList_Create(BMP_WIDTH       // bitmap width
                         ,BMP_HEIGHT      // bitmap height
                         ,0               // creation flags
                         ,NUM_BITMAPS     // number of images
                         ,0               // amount this list );

My third param = ILC_MASK | ILC_COLOR4.
My fifth param = 50;

But that is not the problem. Here is the problem:

You are creating an imagelist and then not associating it with your treeview. Here are the following steps that you need to do if you want your tree view to have icons.

1. Create an imagelist.
2. Set the imagelist of the tree control to that Imagalist using TVM_SETIMAGELIST. In a treeview there are two different imagelists. One for normal state and another for when it is not selected not focused. Most of the time, I pass in TVSIL_NORMAL for TVM_SETIMAGELIST.
3. Add the images to the treeview (which will in turn add them to the imagelist) by sending TVM_INSERTITEM to the treeview with the flag TVIF_IMAGE.

I hope that this helps out. If you have further questions just write back.

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question