Application::EnableVisualStyles Method ()
Enables visual styles for the application.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
This method enables visual styles for the application. Visual styles are the colors, fonts, and other visual elements that form an operating system theme. Controls will draw with visual styles if the control and the operating system support it. To have an effect, EnableVisualStyles() must be called before creating any controls in the application; typically, EnableVisualStyles() is the first line in the Main function. A separate manifest is not required to enable visual styles when calling EnableVisualStyles().
Note |
|---|
Prior to the .NET Framework 2.0, the FlatStyle property of some controls, such as controls that derive from ButtonBase, had to be set to FlatStyle::System in order for the controls to be drawn with visual styles. In applications written with the .NET Framework 2.0, this is no longer necessary. |
Note |
|---|
This method will have no effect for controls hosted in Internet Explorer. |
Visual styles are only supported on these platforms.
The following code example demonstrates calling EnableVisualStyles in the Main function to enable visual styles for the application.
#using <System.dll> #using <System.Windows.Forms.dll> #using <System.Drawing.dll> using namespace System; using namespace System::Drawing; using namespace System::Windows::Forms; namespace VStyles { public ref class Form1: public System::Windows::Forms::Form { private: System::Windows::Forms::Button^ button1; public: Form1() { this->button1 = gcnew System::Windows::Forms::Button; this->button1->Location = System::Drawing::Point( 24, 16 ); this->button1->Size = System::Drawing::Size( 120, 100 ); this->button1->FlatStyle = FlatStyle::System; this->button1->Text = "I am themed."; // Sets up how the form should be displayed and adds the controls to the form. this->ClientSize = System::Drawing::Size( 300, 286 ); this->Controls->Add( this->button1 ); this->Text = "Application::EnableVisualStyles Example"; } }; } [STAThread] int main() { Application::EnableVisualStyles(); Application::Run( gcnew VStyles::Form1 ); }
Available since 1.1
