Use the Windows XP visual style in the SDK and embed it into the EXE

Source: Internet
Author: User
Reference address: border (for example, border rounded) to beautify the interface.
The XP style UI effect is determined by Microsoft. windows. common-Controls provides an implementation. To achieve this effect, you need to make your program dependent on Microsoft. windows. the common-controls component. Microsoft provides manifest to allow us to declare this dependency.

★★★Method 1

Windows XP visual style is not used by default in Win32 programs.
If you are using Visual Studio 2005 and later versions,
You only need to add the following code to stdafx. h:

# Pragma comment (linker, "/manifestdependency: \" type = 'win32 'name = 'Microsoft. windows. common-controls '"version = '6. 0.0.0 'processorarchitecture = '*' publickeytoken = '6595b64144ccf1df 'Language = '*'\"")

Visual style is used by default in MFC, but the following code is used:

01) # ifdef _ Unicode
02) # If defined _ m_ix86
03) # pragma comment (linker, "/manifestdependency: \" type = 'win32 'name = 'Microsoft. windows. common-controls '"version = '6. 0.0.0 'processorarchitecture = 'x86 'publickeytoken = '6595b64144ccf1df' Language = '*'\"")
04) # Elif defined _ m_ia64
05) # pragma comment (linker, "/manifestdependency: \" type = 'win32 'name = 'Microsoft. windows. common-controls '"version = '6. 0.0.0 'processorarchitecture = 'ia64' publickeytoken = '6595b64144ccf1df 'Language = '*'\"")
06) # Elif defined _ m_x64
07) # pragma comment (linker, "/manifestdependency: \" type = 'win32 'name = 'Microsoft. windows. common-controls '"version = '6. 0.0.0 'processorarchitecture = 'amd64' publickeytoken = '6595b64144ccf1df 'Language = '*'\"")
08) # else
09) # pragma comment (linker, "/manifestdependency: \" type = 'win32 'name = 'Microsoft. windows. common-controls '"version = '6. 0.0.0 'processorarchitecture = '*' publickeytoken = '6595b64144ccf1df 'Language = '*'\"")
10) # endif
11) # endif
If your project is ANSI, you can remove # ifdef _ Unicode from the first line and # endif from the last line.

After compilation, a file with the same name extension as the program. manifest is generated as follows:
<? XML version = '1. 0' encoding = 'utf-8' standalone = 'Yes'?>
<Assembly xmlns = 'urn: Schemas-Microsoft-com: ASM. V1 'manifestversion = '1. 0'>
<Dependency>
<Dependentassembly>
<Assemblyidentity type = 'win32 'name = 'Microsoft. windows. common-controls 'version = '6. 0.0.0 'processorarchitecture = '*' publickeytoken = '6595b64144ccf1df 'Language =' * '/>
</Dependentassembly>
</Dependency>
</Assembly>

★★★Method 2
1) define the following line in the. RC file of the Program (in exe)
1 rt_manifest "xpstyle. manifest"
If it is a DLL, it is defined
2 rt_manifest "xpstyle. manifest"
2) Save the following content as xpstyle. manifest

<? 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>
3) Compile the. RC file. The above information will be embedded into the program file along with the resource file.

++ Msdn extension ++ ++
How to: embed a manifest inside a C/C ++ Application
Troubleshooting C/C ++ isolated applications and side-by-side assemblies
About manifest tool(mt.exe)

Bytes
Related Article

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.