Set project icon for tree control

Source: Internet
Author: User

 
Step One: Create an image

Add a bitmap to the resource editor that contains all the icon resources. The following, we use a 13x13 pixel bitmap resource, of course, you can also use different sizes of bitmap resources.

Step Two: Add a variable to the image list
Class Ctreectrlx:public CTreeCtrl
{
Construction
Public
CTREECTRLX ();

Attributes
Public
CImageList M_image;
:
:
:
}

Step three: Create and set up an image list

Call the Create () function, create an image list with the image ID and size given in step one, and set the image list with the SetImageList () function. The process is as follows:
M_tree.m_image. Create (Idb_outline, 1, RGB (255,255,255));
M_tree. SetImageList (& (M_tree.m_image), tvsil_normal);

When used, we call it in the OnInitDialog () function or the OnInitialUpdate () function.

Step four: For each project, specify the image
Once you have assigned an image list for your tree control, when you insert the item into your tree control, you can assign it an icon, and of course you can change it later. InsertItem () and setitemimage () can achieve the above purpose. Tree control requires two different values, one is the item is not selected value, one is the item is selected value, of course, two values can be the same.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.