Sometimes when I use the Win32 API to add controls to a form, the controls created by CreateWindow or CreateWindowEx are not like XP style, but rather like the Windows 2000 style, the interface is hard to see. Note that the CreateWindow is dynamically called to create the control, not loaded from the resource.
In this case, what do we do, generally speaking, caused by the fact that the resources are not loaded properly, we know that the controls such as Button, ComboBox, ListBox, and so on are all placed in the COMCTL32 DLL, so sometimes when you use these system-customized controls , we need to call the Initcommoncontrolsex function first. There are many versions of this DLL, stored under the Windows\winsxs directory, or you directly retrieve: Common control, the results are as follows:
OK, here's the solution:
The basic solution is to add a manifest file with the following content:
<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?>
<assembly xmlns= "urn:schemas-microsoft-com:asm.v1" manifestversion= "1.0" >
<assemblyidentity
Name= "XP style manifest"
Processorarchitecture= "x86"
version= "1.0.0.0"
Type= "Win32"/>
<dependency>
<dependentAssembly>
<assemblyidentity
Type= "Win32"
Name= "Microsoft.windows.common-controls"
version= "6.0.0.0"
Processorarchitecture= "x86"
Publickeytoken= "6595B64144CCF1DF"
Language= "*"
/>
</dependentAssembly>
</dependency>
</assembly>
Save as a file with the suffix:. manifest, which is introduced into the. res file.
That's all.
You also need to add a line to the resource file:
//
1 Rt_manifest "Testctrlstyle.manifest"
Note that sometimes, when you add such a code in a resource file, the link error occurs:
1>linking ...
1>cvtres:fatal Error Cvt1100:duplicate resource. Type:manifest, Name:1, language:0x0409
1>link:fatal error lnk1123:failure during conversion to coff:file invalid or corrupt
The error is that the Rt_manifest file has been included in the project. So at this point, do not add this sentence, directly to add this. manifest file to the project on the line.
The modified interface is as follows:
The above method is to use manifest to set the introduction of the COMCTL32 version, but note the above manifest, which specifies the COMCTL32 platform: processorarchitecture= "x86", If the application wants to run under x64, it will cause a problem: The 64-bit program is linked to a 32-bit COMCTL32 library and the creation of the control fails. So the best solution is the following:
Add the following statement to the header file:
#ifdef _UNICODE
#if defined _m_ix86
#pragma COMMENT (linker, "/manifestdependency:\" Type= ' Win32 ' Name= ' Microsoft.windows.common-controls ' version= ' 6.0.0.0 ' processorarchitecture= ' x86 ' publickeytoken= ' 6595b64144ccf1df ' language= ' * ' \ ' "")
#elif defined _m_ia64
#pragma COMMENT (linker, "/manifestdependency:\" Type= ' Win32 ' Name= ' Microsoft.windows.common-controls ' version= ' 6.0.0.0 ' processorarchitecture= ' ia64 ' publickeytoken= ' 6595b64144ccf1df ' language= ' * ' \ ' "")
#elif defined _m_x64
#pragma COMMENT (linker, "/manifestdependency:\" Type= ' Win32 ' Name= ' Microsoft.windows.common-controls ' version= ' 6.0.0.0 ' processorarchitecture= ' amd64 ' publickeytoken= ' 6595b64144ccf1df ' language= ' * ' \ ' "")
#else
#pragma COMMENT (linker, "/manifestdependency:\" Type= ' Win32 ' Name= ' Microsoft.windows.common-controls ' version= ' 6.0.0.0 ' processorarchitecture= ' * ' publickeytoken= ' 6595b64144ccf1df ' language= ' * ' "")
#endif
#endif
This is based on the compilation options to specify what version of the library, so the compiled program will not have the above problems.
Transferred from: http://blog.sina.com.cn/s/blog_5f8817250100u2yr.html
"Go" Win32 create control style not win XP solution