Application.EnableVisualStyles Método

Definição

Permite estilos visuais para o aplicativo.Enables visual styles for the application.

public:
 static void EnableVisualStyles();
public static void EnableVisualStyles ();
static member EnableVisualStyles : unit -> unit
Public Shared Sub EnableVisualStyles ()

Exemplos

O exemplo de código a seguir demonstra como chamar EnableVisualStyles na função Main para Habilitar estilos visuais para o aplicativo.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 );
}

using System;
using System.Drawing;
using System.Windows.Forms;

namespace VStyles
{
    public class Form1 : System.Windows.Forms.Form
    {

        private System.Windows.Forms.Button button1;
        
        [STAThread]
        static void Main() 
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button1.Location = new System.Drawing.Point(24, 16);
            this.button1.Size = new 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 = new System.Drawing.Size(300, 286);
            this.Controls.Add(this.button1);

            this.Text = "Application.EnableVisualStyles Example";

        }
    }
}
Imports System.Drawing
Imports System.Windows.Forms

Namespace VStyles
    
    ' Summary description for Form1.
    Public Class Form1
        Inherits System.Windows.Forms.Form

        Private button1 As System.Windows.Forms.Button

        <System.STAThread()> _
        Public Shared Sub Main()

            System.Windows.Forms.Application.EnableVisualStyles()
            System.Windows.Forms.Application.Run(New Form1)
        End Sub

        Public Sub New()

            Me.button1 = New System.Windows.Forms.Button()
            Me.button1.Location = New System.Drawing.Point(24, 16)
            Me.button1.Size = New System.Drawing.Size(120, 100)
            Me.button1.FlatStyle = FlatStyle.System
            Me.button1.Text = "I am themed."

            ' Sets up how the form should be displayed and adds the controls to the form.
            Me.ClientSize = New System.Drawing.Size(300, 286)
            Me.Controls.Add(Me.button1)

            Me.Text = "Application.EnableVisualStyles Example"
        End Sub

    End Class
End Namespace 'VStyles

Comentários

Esse método habilita estilos visuais para o aplicativo.This method enables visual styles for the application. Os estilos visuais são as cores, as fontes e outros elementos visuais que formam um tema do sistema operacional.Visual styles are the colors, fonts, and other visual elements that form an operating system theme. Os controles serão desenhados com estilos visuais se o controle e o sistema operacional oferecerem suporte a ele.Controls will draw with visual styles if the control and the operating system support it. Para ter um efeito, EnableVisualStyles() deve ser chamado antes de criar qualquer controle no aplicativo; Normalmente, EnableVisualStyles() é a primeira linha na função Main.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. Um manifesto separado não é necessário para Habilitar estilos visuais ao chamar EnableVisualStyles().A separate manifest is not required to enable visual styles when calling EnableVisualStyles().

Observação

Antes do .NET Framework 2,0, a propriedade FlatStyle de alguns controles, como controles que derivam de ButtonBase, precisava ser definida como FlatStyle.System para que os controles sejam desenhados com estilos visuais.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. Em aplicativos escritos com o .NET Framework 2,0, isso não é mais necessário.In applications written with the .NET Framework 2.0, this is no longer necessary.

Observação

Esse método não terá nenhum efeito para controles hospedados no Internet Explorer.This method will have no effect for controls hosted in Internet Explorer.

Aplica-se a

Veja também