Application.EnableVisualStyles メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


このメソッドを使用すると、アプリケーションで visual スタイルが有効になります。コントロールとオペレーティング システムが visual スタイルをサポートしている場合は、visual スタイルでコントロールが描画されます。この visual スタイルを有効にするには、アプリケーションでコントロールを作成する前に、EnableVisualStyles を呼び出す必要があります。通常は、Main 関数の 1 行目に EnableVisualStyles を記述します。EnableVisualStyles を呼び出した場合は、別のマニフェストがなくても、visual スタイルが有効になります。
![]() |
---|
.NET Framework 2.0 より前では、ButtonBase から派生したコントロールなどの一部のコントロールの FlatStyle プロパティは、visual スタイルを使用してコントロールを描画するために FlatStyle.System に設定する必要がありました。.NET Framework 2.0 を使用して作成したアプリケーションでは、これは必要ありません。 |
Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 プラットフォームメモ : visual スタイルは、これらのプラットフォームでのみサポートされます。

アプリケーションで visual スタイルを有効にするために、Main 関数の中で EnableVisualStyles を呼び出すコード例を次に示します。
Imports System 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 'Main 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 'New End Class 'Form1 End Namespace 'VStyles
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"; } } }
#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 ); }
package VStyles; import System.*; import System.Drawing.*; import System.Windows.Forms.*; public class Form1 extends System.Windows.Forms.Form { private System.Windows.Forms.Button button1; /** @attribute STAThread() */ public static void main(String[] args) { Application.EnableVisualStyles(); Application.Run(new Form1()); } //main public Form1() { this.button1 = new System.Windows.Forms.Button(); this.button1.set_Location(new System.Drawing.Point(24, 16)); this.button1.set_Size(new System.Drawing.Size(120, 100)); this.button1.set_FlatStyle(FlatStyle.System); this.button1.set_Text("I am themed."); // Sets up how the form should be displayed and adds the controls // to the form. this.set_ClientSize(new System.Drawing.Size(300, 286)); this.get_Controls().Add(this.button1); this.set_Text("Application.EnableVisualStyles Example"); } //Form1 } //Form1

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Application クラス
Application メンバ
System.Windows.Forms 名前空間
RenderWithVisualStyles
VisualStyleState
FlatStyle
Weblioに収録されているすべての辞書からApplication.EnableVisualStyles メソッドを検索する場合は、下記のリンクをクリックしてください。

- Application.EnableVisualStyles メソッドのページへのリンク