VC is free of burden to implement XP style interface selection from goodname008 blog

Source: Internet
Author: User

The runtime in XP or 2003 (Themes Service must be started) will display the XP interface style.

In other words, test.exe must first call the initcommoncontrols function (abolished, not recommended) or the initcommoncontrolsex function to register component classes from comctl32.dll. This step is required in VB, but in VC (MFC Program), we seem to have not called this function, but why can the compiled program implement the XP style? The reason is that MFC did this for us. If we have the window class registered with MFC, it will call the _ afxinitcommoncontrols function, and the main operation of _ afxinitcommoncontrols is to load comctl32.dll and then judge. is there any initcommoncontrolsex function in the DLL file? If yes, call it. If no, call initcommoncontrols. Some people may look at the name of the window class starting with "afx" like me, so they like to register the window class themselves, however, when registering our own window class, make sure that the initcommoncontrolsex function has been called. Remember that if you forget it, you will see a blank window.

Having said so much, I am a little confused. Now return to the topic. The method I mentioned above is described on many websites, but it has a fatal drawback, that is, it must be included. the manifest file is like a shadow file, and where the EXE file is located, it will be like this. Of course we don't want to see it. Is there a way to "merge" it into the EXE file? The answer is yes, which is exactly the meaning of the word "no burden" in this article.

The hosts file is merged.

First, obtain the. manifest file:


<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>

<Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0">


Name = "XP style manifest"

Processorarchitecture = "x86"

Version =" 1.0.0 . 0"

Type = "Win32"/>




Type = "Win32"

Name = "Microsoft. Windows. Common-Controls"

Version =" 6.0.0 . 0"

Processorarchitecture = "x86"

Publickeytoken = "6595b64144ccf1df"

Language = "*"






As you can see, this is actually an XML file. Open notepad, copy the above content, save the disk, and the file name is arbitrary. Here I save it as xpstyle. manifest.

Create an MFC Appwizard (exe) project in VC, either document/view or dialog, and then set the xpstyle. copy the manifest file to the project directory, and then use notepad or other text editing tools to manually modify the resource files under the project directory (. RC), add a line at the end of the file:


1 24 "xpstyle. manifest"


Compile and connect the project generation. EXE executable file in vcss and run it.

Is that simple? That's simple.

Here I will explain more. The last line added, "1" represents the resource ID, which must be "1 ". "24" indicates the resource type. I think we are very familiar with resources such as rt_accelerator, rt_bitmap, rt_menu, and rt_string. "24" is actually rt_manifest. The last quotation marks will not repeat me any more.

After compilation, the. exe file can be obtained anywhere. It is an XP-style interface, and you no longer need to rely on the. manifest file. Oh, of course, it must be in an XP or 2003 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: 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.