다음을 통해 공유


Control.Capture 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Property Capture As Boolean
‘사용 방법
Dim instance As Control
Dim value As Boolean

value = instance.Capture

instance.Capture = value
public bool Capture { get; set; }
public:
property bool Capture {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_Capture ()

/** @property */
public void set_Capture (boolean value)
public function get Capture () : boolean

public function set Capture (value : boolean)

속성 값

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

설명

컨트롤이 마우스를 캡처했으면 커서가 테두리 내에 있는지 여부에 관계 없이 컨트롤이 마우스 입력을 받습니다. 마우스는 대개 끌기 작업 동안에만 캡처됩니다.

전경 창만이 마우스를 캡처할 수 있습니다. 배경 창이 마우스를 캡처하려고 하면 창은 마우스 커서가 창의 보이는 부분 내에 있을 때 발생하는 마우스 이벤트의 메시지만 받습니다. 또한 전경 창이 마우스를 캡처했더라도 다른 창을 클릭하여 전경으로 가져올 수도 있습니다.

마우스가 캡처되면 바로 가기 키를 사용할 수 없습니다.

예제

다음 예제에서는 Capture 속성을 보여 줍니다. 이 예제를 실행하려면 label1이라는 Label 한 개와 각각 listbox1 및 listbox2라는 Listbox 컨트롤 두 개가 들어 있는 폼에 다음 코드를 붙여넣고 폼 및 컨트롤의 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.
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
// 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.
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(Object sender, 
    System.Windows.Forms.MouseEventArgs e)
{
    Control control = (Control)sender;
    if (control.get_Capture()) {
        label1.set_Text(control.get_Name() + " has captured the mouse");
    }
} //Control_MouseDown

.NET Framework 보안

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
Cursor