A workaround for the CTreeCtrl control not to display icons under the XP system

Source: Internet
Author: User

In the recent project, encountered such a difficult problem, finally took a day to solve, now summed up, for your reference!

Problem: The original project works in the XP system with VC6 written, all no problem. But because the reality needs to run in the WIN7/XP system, we turn the project to VC2010, there is no problem in the WIN7. But in XP there is a inexplicable problem: is the CTreeCtrl control BMP icon does not display, in the Display icon where all do not display (empty), after repeated detection, verify that the code is not a problem (there is no problem in the WIN7 system).

The CTreeCtrl control code for the display icon is as follows:

. h file

CTreeCtrl M_tree;
CImageList m_img;


. cpp Files

M_tree.create (Ws_child | ws_visible | Tvs_haslines | Tvs_linesatroot | Tvs_hasbuttons, CRect (0,0,200,400), this, 0x09992);

M_img.create (+, Ilc_color | Ilc_mask, 1, 1);

CBitmap bmp;


Bmp. LoadBitmap (IDB_BITMAP1);

int iNo = M_img.add (&bmp, RGB (255,255,255));

Bmp. Detach ();


Bmp. DeleteObject ();

M_wndstationtree.setimagelist (&m_img, tvsil_normal);

Htreeitem HPA = M_wndstationtree.insertitem ("123", INo, INo);


M_wndstationtree.insertitem ("456", 0, 0, HPA);


After the idiom runs, it does not display the icon in front of the item. The following unintentional modification, found the problem, the culprit was "xptheme.xml" file, the contents of the file are as follows:

//////////////////////////////////////////////////////////////////////////////////////////////

<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?>
<assembly
Xmlns= "Urn:schemas-microsoft-com:asm.v1"
Manifestversion= "1.0" >
<assemblyidentity
Processorarchitecture= "x86"
version= "5.1.0.0"
Type= "Win32"
Name= "Xxxexe"/>
<description>xxx application</description>
<dependency>
<dependentAssembly>
<assemblyidentity
Type= "Win32"
Name= "Microsoft.windows.common-controls"
version= "6.0.0.0"
Publickeytoken= "6595B64144CCF1DF"
Language= "*"
Processorarchitecture= "x86"/>
</dependentAssembly>
</dependency>
</assembly>

/////////////////////////////////////////////////////////////////////////////////////////////

Perhaps a friend of this file is not unfamiliar, his main role is that we write the software has XP style, and very simple and practical.

But this is the file that caused the above problem, delete this file and the corresponding resource definition can be.

Why is that? may be incompatible with it, I do not quite understand! Have to know can leave a message below, let me long to see ~~~~~~~~~~~~~.


Good memory is not as bad as writing, convenient oneself also convenient others, hope can help you ...


A workaround for the CTreeCtrl control not to display icons under the XP system

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.