GraphicsUnit 列挙型

定義

指定のデータの長さの単位を指定します。

public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit = 
Public Enum GraphicsUnit
継承
GraphicsUnit

フィールド

Display 1

表示デバイスの長さの単位を指定します。 通常、ビデオ ディスプレイにはピクセル、プリンターには 1/100 インチを指定します。

Document 5

ドキュメント単位 (1/300 インチ) を長さの単位に指定します。

Inch 4

インチを長さの単位に指定します。

Millimeter 6

ミリメートルを長さの単位に指定します。

Pixel 2

デバイス ピクセルを長さの単位に指定します。

Point 3

プリンター ポイント (1/72 インチ) を長さの単位に指定します。

World 0

ワールド座標系を長さの単位に指定します。

次のコード例では、 列挙を使用してハンドルからビットマップを Icon 読み込み、 メソッドを使用して GraphicsUnit ビットマップの Round 四角形の境界を描画する方法を示します。

この例は、Windows フォームで使用するように設計されています。 Button2 という名前のボタンを含むフォームを作成します。 コードをフォームに貼り付け、このメソッドをボタンの Click イベントに関連付けます。

void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   Bitmap^ bitmap1 = Bitmap::FromHicon( SystemIcons::Hand->Handle );
   Graphics^ formGraphics = this->CreateGraphics();
   GraphicsUnit units = GraphicsUnit::Point;
   RectangleF bmpRectangleF = bitmap1->GetBounds( units );
   Rectangle bmpRectangle = Rectangle::Round( bmpRectangleF );
   formGraphics->DrawRectangle( Pens::Blue, bmpRectangle );
   delete formGraphics;
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{

    Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Hand.Handle);
    Graphics formGraphics = this.CreateGraphics();
    GraphicsUnit units = GraphicsUnit.Point;

    RectangleF bmpRectangleF = bitmap1.GetBounds(ref units);
    Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);
    formGraphics.DrawRectangle(Pens.Blue, bmpRectangle);
    formGraphics.Dispose();
}
Private Sub Button2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button2.Click

    Dim bitmap1 As Bitmap = Bitmap.FromHicon(SystemIcons.Hand.Handle)
    Dim formGraphics As Graphics = Me.CreateGraphics()
    Dim units As GraphicsUnit = GraphicsUnit.Point
    Dim bmpRectangleF As RectangleF = bitmap1.GetBounds(units)
    Dim bmpRectangle As Rectangle = Rectangle.Round(bmpRectangleF)
    formGraphics.DrawRectangle(Pens.Blue, bmpRectangle)
    formGraphics.Dispose()
End Sub

適用対象