XP-style interface

Source: Internet
Author: User
XP-style interface

When Windows XP was released, many of us were impressed by her gorgeous and beautiful interface. However, when net1.0 was released, many of us, including myself, were disappointed that it did not support the XP style. But in fact, in Windows XP (only Windows XP),. Net supports the XP style, but you only need to do a little work.

This article mainly references http://www.codeproject.com/csharp/dotnetvisualstyles.asp
Follow the steps below to make your program have an XP-style interface, go!

1. Create a new windows application, open assemblyinfo. CS, and modify the content. The following is the sample code:
Using system. reflection;
Using system. runtime. compilerservices;

[Assembly: assemblytitle ("ABC")]
[Assembly: assemblydescription ("ABC")]
[Assembly: assemblyconfiguration ("")]
[Assembly: assemblycompany ("")]
[Assembly: assemblyproduct ("")]
[Assembly: assemblycopyright ("")]
[Assembly: assemblytrademark ("")]
[Assembly: assemblyculture ("")]
[Assembly: assemblyversion ("1.0.0.0")]
[Assembly: assemblydelaysign (false)]
[Assembly: assemblykeyfile ("")]
[Assembly: assemblykeyname ("")]

2. Add a new project to the project. Add a new XML file and name it your program name cmd.exe. manifest. [your program name] refers to the executable program name generated in the./bin/debug folder. File Content example. modify version = "1.0.0.0", name = "ABC", <description> ABC </description> In CS.

<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
<Assembly
Xmlns = "urn: Schemas-Microsoft-com: ASM. V1"
Manifestversion = "1.0">
<Assemblyidentity
Version = "1.0.0.0"
Processorarchitecture = "x86"
Name = "ABC"
Type = "Win32"/>
<Description> ABC </description>
<Dependency>
<Dependentassembly>
<Assemblyidentity
Type = "Win32"
Name = "Microsoft. Windows. Common-Controls"
Version = "6.0.0.0"
Processorarchitecture = "x86"
Publickeytoken = "6595b64144ccf1df"
Language = "*"/>
</Dependentassembly>
</Dependency>
</Assembly>

Recompile the program. Note: Components inherited from buttonbase, groupbox, and label must set the flatstyle attribute to system.

3. Add your program name cmd.exe. manifest to the executable file of the program.

(1) choose menu> File> Open. Open./bin/debug/program your program name is cmd.exe. Now you can see a resource browsing tree;
(2) Right-click the root directory [your program name] and click "Add Resource ...";
(3) In the displayed dialog box, click "custom ...";
(4) Name the resource type rt_manifest. OK;
(5) double-click the item under rt_manifest of the Resource Tree (usually 101), copy the file to your program name cmd.exe. the content of manifest is pasted in the open file, and the paste result is in binary format (the result is a bit strange, ignore it );
(6) Save, change the ID of item 101 to 1, and then save. Note: Do not recompile the program.

Now, how can I re-open your program? The interface should be good.

Principle:
The key to the problem lies in comctl32.dll. Search for your computer and you will find two comctl32.dll files. The component exterior is associated with the specific resources in the two DLL, which provide specific resources for drawing the component customer region. For components inherited from buttonbase, groupbox, and label, set their flatstyle attribute to system to allow the system to draw components.
By default, the system will use .. for the DLL in the/Windows/system32 directory, you need to tell the system to use another DLL, which is to compile your program name cmd.exe. add the manifest file to the executable file.
The following is a complete list of components that support the XP style:
Label, Textbox, RichTextBox, hscrollbox, vscrollbox, progressbar, tabcontrol, mainmenu, ComboBox, contextmenu, DataGrid, ListBox, listview, Treeview, datatimepicker, monthcalendar, splitter, trackbar, statusbar, Toolbar

In addition, you can use this function to add statements to main.

Static void main ()
{
Application. enablevisualstyles ();
Application. Run (New frmmain ());
}

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.