Icon.Handle プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
使用例
GraphicsUnit 列挙体を使用してビットマップを Icon ハンドルから読み込む方法と、Round メソッドを使用してビットマップの外接する四角形を描画する方法を次のコード例に示します。
この例は、Windows フォームでの使用を意図してデザインされています。Button2 という名前のボタンを格納するフォームを作成します。コードをフォームに貼り付け、このメソッドをボタンの Click イベントに関連付けます。
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
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(); }
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.get_Hand().get_Handle()); Graphics formGraphics = this.CreateGraphics(); GraphicsUnit units = GraphicsUnit.Point; RectangleF bmpRectangleF = bitmap1.GetBounds(units); Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF); formGraphics.DrawRectangle(Pens.get_Blue(), bmpRectangle); formGraphics.Dispose(); } //button2_Click
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Icon.Handle プロパティのページへのリンク