GraphicsUnit 列挙型
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定されたデータの測定単位を指定します。
public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit =
Public Enum GraphicsUnit
- 継承
フィールド
| 名前 | 値 | 説明 |
|---|---|---|
| World | 0 | ワールド座標系の単位を測定単位として指定します。 |
| Display | 1 | 表示デバイスの測定単位を指定します。 通常、ビデオ ディスプレイの場合はピクセル、プリンターの場合は 1/100 インチです。 |
| Pixel | 2 | デバイス ピクセルを測定単位として指定します。 |
| Point | 3 | 測定単位としてプリンターのポイント (1/72 インチ) を指定します。 |
| Inch | 4 | インチを測定単位として指定します。 |
| Document | 5 | 文書の単位 (1/300 インチ) を測定単位として指定します。 |
| Millimeter | 6 | 測定単位としてミリメートルを指定します。 |
例
次のコード例では、GraphicsUnit列挙型を使用してIcon ハンドルからビットマップを読み込む方法と、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