Control.Capture 속성

정의

컨트롤이 마우스를 캡처했는지를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Capture { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool Capture { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Capture : bool with get, set
Public Property Capture As Boolean

속성 값

컨트롤이 마우스를 캡처했으면 true이고, 그렇지 않으면 false입니다.

특성

예제

다음 코드 예제는 Capture 속성입니다. 이 예제를 실행하려면 명명된 label1과 listbox1 및 listbox2라는 두 개의 ListBox 컨트롤이 포함된 Label 양식에 다음 코드를 붙여넣습니다. 폼 및 컨트롤의 MouseDown 이벤트가 이 예제의 메서드와 연결되어 있는지 확인합니다.

// This method handles the mouse down event for all the controls on the form.  
// When a control has captured the mouse
// the control's name will be output on label1.
void Control_MouseDown( System::Object^ sender,
   System::Windows::Forms::MouseEventArgs^ /*e*/ )
{
   Control^ control = (Control^)(sender);
   if ( control->Capture )
   {
      label1->Text = control->Name + " has captured the mouse";
   }
}
// This method handles the mouse down event for all the controls on the form.  
// When a control has captured the mouse
// the control's name will be output on label1.
private void Control_MouseDown(System.Object sender, 
    System.Windows.Forms.MouseEventArgs e)
{
    Control control = (Control) sender;
    if (control.Capture)
    {
        label1.Text = control.Name+" has captured the mouse";
    }
}
'This method handles the mouse down event for all the controls on the form.  When a control has
'captured the mouse, the control's name will be output on label1.
Private Sub Control_MouseDown(ByVal sender As System.Object, _
    ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown, _
    label1.MouseDown, listbox1.MouseDown, listbox2.MouseDown
    Dim control As Control = CType(sender, Control)
    If (control.Capture) Then
        label1.Text = control.Name & " has captured the mouse"
    End If
End Sub

설명

컨트롤이 마우스를 캡처하면 커서가 테두리 내에 있는지 여부에 관계없이 마우스 입력을 받습니다. 마우스는 일반적으로 끌기 작업 중에만 캡처됩니다.

전경 창만 마우스를 캡처할 수 있습니다. 백그라운드 창이 이렇게 하려고 하면 창은 마우스 커서가 창의 표시되는 부분 내에 있을 때 발생하는 마우스 이벤트에 대해서만 메시지를 받습니다. 또한 전경 창이 마우스를 캡처한 경우에도 사용자는 다른 창을 클릭하여 이 창을 전경으로 가져올 수 있습니다.

마우스가 캡처되면 바로 가기 키가 작동하지 않아야 합니다.

적용 대상

추가 정보