Control.Handle Propriété
Définition
Obtient le handle de fenêtre auquel le contrôle est lié.Gets the window handle that the control is bound to.
public:
property IntPtr Handle { IntPtr get(); };
[System.ComponentModel.Browsable(false)]
public IntPtr Handle { get; }
member this.Handle : nativeint
Public ReadOnly Property Handle As IntPtr
Valeur de propriété
IntPtr qui contient le handle de fenêtre (HWND
) du contrôle.An IntPtr that contains the window handle (HWND
) of the control.
Implémente
- Attributs
Exemples
L’exemple de code suivant illustre l’utilisation de la ControlPaint.DrawFocusRectangle et de la propriété Handle.The following code example demonstrates using the ControlPaint.DrawFocusRectangle and the Handle property. Pour exécuter l’exemple, collez le code suivant dans un formulaire.To run the example paste the following code in a form. Ajoutez deux boutons nommés Button1
et Button2
au formulaire et vérifiez que tous les événements sont connectés à leurs gestionnaires d’événements.Add two buttons named Button1
and Button2
to the form and ensure all events are connected to their event handlers.
// 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
Remarques
La valeur de la propriété Handle est Windows HWND
.The value of the Handle property is a Windows HWND
. Si le handle n’a pas encore été créé, le fait de référencer cette propriété forcera la création du handle.If the handle has not yet been created, referencing this property will force the handle to be created.