Condividi tramite


Control.Handle Proprietà

Definizione

Ottiene l'handle di finestra a cui è associato il controllo.

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

nativeint

Oggetto IntPtr contenente l'handle di finestra (HWND) del controllo .

Implementazioni

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato l'utilizzo della ControlPaint.DrawFocusRectangleHandle proprietà e . Per eseguire l'esempio incollare il codice seguente in un modulo. Aggiungere due pulsanti denominati Button1 e Button2 al modulo e assicurarsi che tutti gli eventi siano connessi ai gestori eventi.

// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   ControlPaint::DrawFocusRectangle( Graphics::FromHwnd( Button2->Handle ), Button2->ClientRectangle );
}
// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), 
        Button2.ClientRectangle);
}
' This method draws a focus rectangle on Button2 using the 
' handle and client rectangle of Button2.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), _
    Button2.ClientRectangle)
End Sub

Commenti

Il valore della Handle proprietà è windows HWND. Se l'handle non è ancora stato creato, fare riferimento a questa proprietà forza la creazione dell'handle.

Si applica a

Vedi anche