Control.Handle 속성

정의

컨트롤이 바인딩되는 창 핸들을 가져옵니다.

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

속성 값

IntPtr

nativeint

컨트롤의 창 핸들(IntPtr)이 포함된 HWND입니다.

구현

특성

예제

다음 코드 예제에서는 사용 하 고 속성을 보여 ControlPaint.DrawFocusRectangle 줍니다 Handle . 예제를 실행하려면 양식에 다음 코드를 붙여넣습니다. 명명된 Button1 Button2 두 개의 단추를 폼에 추가하고 모든 이벤트가 해당 이벤트 처리기에 연결되어 있는지 확인합니다.

// 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

설명

속성 값은 Handle Windows HWND입니다. 핸들이 아직 만들어지지 않은 경우 이 속성을 참조하면 핸들이 강제로 만들어집니다.

적용 대상

추가 정보