Icon.Handle Proprietà

Definizione

Ottiene l'handle di Windows per questo oggetto Icon.Gets the Windows handle for this Icon. Non si tratta di una copia dell'handle, pertanto non deve essere liberata.This is not a copy of the handle; do not free it.

public:
 property IntPtr Handle { IntPtr get(); };
[System.ComponentModel.Browsable(false)]
public IntPtr Handle { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Handle : nativeint
Public ReadOnly Property Handle As IntPtr

Valore della proprietà

IntPtr

Handle di Windows per l'icona.The Windows handle for the icon.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come caricare una bitmap da un Icon handle utilizzando l' GraphicsUnit enumerazione e come utilizzare il Round metodo per creare i limiti del rettangolo di una bitmap.The following code example demonstrates how to load a bitmap from an Icon handle using the GraphicsUnit enumeration and how to use the Round method to draw the rectangle bounds of a bitmap.

Questo esempio è progettato per essere usato con Windows Forms.This example is designed to be used with Windows Forms. Creare un modulo che contenga un pulsante denominato Button2 .Create a form that contains a button named Button2. Incollare il codice nel form e associare questo metodo all'evento del pulsante Click .Paste the code into the form and associate this method with the button's Click event.

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

Si applica a