Control.Capture プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

/** @property */ public boolean get_Capture () /** @property */ public void set_Capture (boolean value)
コントロールがマウスをキャプチャした場合は true。それ以外の場合は false。

コントロールがマウスをキャプチャしていた場合は、カーソルが境界内にあるかどうかにかかわらず、マウス入力を受け取ります。通常、マウスはドラッグ操作中にだけキャプチャされます。
前面のウィンドウだけがマウスをキャプチャできます。背面のウィンドウがマウスをキャプチャしようとすると、ウィンドウは、マウス カーソルがウィンドウの表示部分内にあるときに発生したマウス イベントのメッセージだけを受け取ります。また、前面のウィンドウがマウスをキャプチャした場合でも、ユーザーは別のウィンドウをクリックすると、そのウィンドウを前面に表示できます。
マウスがキャプチャされると、ショートカット キーは動作しません。

Capture プロパティのコード例を次に示します。この例を実行するには、label1 という名前の Label と、listbox1 および listbox2 という名前の 2 つの 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


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.Capture プロパティを検索する場合は、下記のリンクをクリックしてください。

- Control.Capture プロパティのページへのリンク