Enable visual styles for applications in. net

Source: Internet
Author: User

I. Role of application. enablevisualstyles ()


Definition:

Publicstaticvoidenablevisualstyles ()

This method enables visual styles for applications. If the controls and Operating Systems Support visual styles, the controls are drawn in visual styles. To enablevisualstyles take effect, you must call it before creating any control in the application. enablevisualstyles is usually the first line of the main function.

When you call enablevisualstyles, you can enable the visual style without a separate list.

[STAThread]static void Main(){      Application.EnableVisualStyles();      Application.SetCompatibleTextRenderingDefault(false)      Application.Run(new Form1());}


To put it simply, let your controls (including forms) be displayed. If you build a winform program, don't call it and try to see what the result will be.
 
2. What does application. setcompatibletextrenderingdefault (false) mean? The main idea is as follows:

1. Purpose: Set the default mode for displaying the control text within the application scope (it can be set to use the new GDI + or the old GDI)

True: displays text in the mode of GDI +,
False: displays text in GDI mode.

2. You can only call this method in a program that runs the form separately. You cannot call this method in a plug-in program.

3. This method can only be called before the program creates any form. Otherwise, an invalidoperationexception occurs.

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.