ControlPaint クラスとは? わかりやすく解説

ControlPaint クラス

共通の Windows コントロールとその要素描画するために使用するメソッド提供します。このクラス継承できません。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public NotInheritable Class
 ControlPaint
public sealed class ControlPaint
public ref class ControlPaint sealed
public final class ControlPaint
public final class ControlPaint
解説解説
使用例使用例

ControlPaintコンストラクタ1 つ使用してフラットな Button コントロール描画するコード例次に示します

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

    Public Class Form1
        Inherits System.Windows.Forms.Form

        Private button1 As System.Windows.Forms.Button
 = New Button
        Private button2 As System.Windows.Forms.Button
 = New Button

        <System.STAThreadAttribute()>  _
        Public Shared Sub
 Main()
            System.Windows.Forms.Application.Run(New Form1)
        End Sub

        Public Sub New()
            Me.button2.Location = New Point(0,
 button1.Height + 10)
            AddHandler Me.button2.Click, AddressOf
 Me.button2_Click
            Me.Controls.Add(Me.button1)
            Me.Controls.Add(Me.button2)
        End Sub

        Private Sub button2_Click(sender As
 Object, e As System.EventArgs)
            ' Draws a flat button on button1.
            ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(button1.Handle),
 0, 0, button1.Width, button1.Height, ButtonState.Flat)
        End Sub 'button2_Click
End Class
using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
      private Button button1 = new Button();
      private Button button2 = new Button();


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


    public Form1(){
        this.button2.Location = new Point(0,
 button1.Height + 10);
        this.Click += new EventHandler(this.button2_Click);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.button2);
    }

    private void button2_Click(object sender,
 System.EventArgs e)
    {
        // Draws a flat button on button1.
        ControlPaint.DrawButton(
        System.Drawing.Graphics.FromHwnd(button1.Handle),0,0,button1.Width,button1.Height
,
                ButtonState.Flat);
    }
}
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public
 Form
{
private:
   Button^ button1;
   Button^ button2;

public:
   Form1()
   {
      button1 = gcnew Button;
      button2 = gcnew Button;
      this->button2->Location = Point(0,button1->Height
 + 10);
      this->Click += gcnew EventHandler( this,
 &Form1::button2_Click );
      this->Controls->Add( this->button1
 );
      this->Controls->Add( this->button2
 );
   }


private:

   void button2_Click( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      
      // Draws a flat button on button1.
      ControlPaint::DrawButton( System::Drawing::Graphics::FromHwnd( button1->Handle
 ), 0, 0, button1->Width, button1->Height, ButtonState::Flat );
   }

};


[STAThread]
void main()
{
   Application::Run( gcnew Form1 );
}

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;

public class Form1 extends Form
{
    private Button button1 = new Button();
    private Button button2 = new Button();

    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.button2.set_Location(new Point(0,
 button1.get_Height() + 10));
        this.add_Click(new EventHandler(this.button2_Click));
        this.get_Controls().Add(this.button1);
        this.get_Controls().Add(this.button2);
    } //Form1

    private void button2_Click(Object sender,
 System.EventArgs e)
    {
        // Draws a flat button on button1.
        ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(
            button1.get_Handle()), 0, 0, button1.get_Width(), 
            button1.get_Height(), ButtonState.Flat);
    } //button2_Click
} //Form1
継承階層継承階層
System.Object
  System.Windows.Forms.ControlPaint
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ControlPaint クラス」の関連用語

ControlPaint クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ControlPaint クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS