QueryContinueDragEventArgs 类
定义
为 QueryContinueDrag 事件提供数据。Provides data for the QueryContinueDrag event.
public ref class QueryContinueDragEventArgs : EventArgs
public class QueryContinueDragEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class QueryContinueDragEventArgs : EventArgs
type QueryContinueDragEventArgs = class
inherit EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type QueryContinueDragEventArgs = class
inherit EventArgs
Public Class QueryContinueDragEventArgs
Inherits EventArgs
- 继承
- 属性
示例
此代码摘录演示了如何将 QueryContinueDragEventArgs 类与 QueryContinueDrag 事件一起使用。This code excerpt demonstrates using the QueryContinueDragEventArgs class with the QueryContinueDrag event. DoDragDrop有关完整的代码示例,请参阅方法。See the DoDragDrop method for the complete code example.
void ListDragSource_QueryContinueDrag( Object^ sender, System::Windows::Forms::QueryContinueDragEventArgs^ e )
{
// Cancel the drag if the mouse moves off the form.
ListBox^ lb = dynamic_cast<ListBox^>(sender);
if ( lb != nullptr )
{
Form^ f = lb->FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if ( ((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) || ((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) || ((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) || ((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom) )
{
e->Action = DragAction::Cancel;
}
}
}
private void ListDragSource_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
// Cancel the drag if the mouse moves off the form.
ListBox lb = sender as ListBox;
if (lb != null)
{
Form f = lb.FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) ||
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) ||
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) ||
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom))
{
e.Action = DragAction.Cancel;
}
}
}
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
' Cancel the drag if the mouse moves off the form.
Dim lb As ListBox = CType(sender, ListBox)
If (lb IsNot Nothing) Then
Dim f As Form = lb.FindForm()
' Cancel the drag if the mouse moves off the form. The screenOffset
' takes into account any desktop bands that may be at the top or left
' side of the screen.
If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then
e.Action = DragAction.Cancel
End If
End If
End Sub
注解
此 QueryContinueDrag 事件在拖放操作期间发生,并且允许拖动源确定是否应取消拖放操作。The QueryContinueDrag event occurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled. QueryContinueDragEventArgs指定是否以及如何进行拖放操作、是否按下任何修改键,以及用户是否已按 ESC 键。A QueryContinueDragEventArgs specifies whether and how the drag-and-drop operation should proceed, whether any modifier keys are pressed, and whether the user has pressed the ESC key.
默认情况下,如果按 Esc 键,则 QueryContinueDrag 事件将 Action 设置为 DragAction.Cancel;如果按鼠标左键、中键或右键,则将 Action
设置为 DragAction.Drop。By default, the QueryContinueDrag event sets Action to DragAction.Cancel if the ESC key was pressed and sets Action
to DragAction.Drop if the left, middle, or right mouse button is pressed.
有关事件模型的信息,请参阅 处理和引发事件。For information about the event model, see Handling and Raising Events.
构造函数
QueryContinueDragEventArgs(Int32, Boolean, DragAction) |
初始化 QueryContinueDragEventArgs 类的新实例。Initializes a new instance of the QueryContinueDragEventArgs class. |
属性
Action |
获取或设置拖放操作的状态。Gets or sets the status of a drag-and-drop operation. |
EscapePressed |
获取该用户是否按下 Esc 键。Gets whether the user pressed the ESC key. |
KeyState |
获取 Shift、Ctrl 和 Alt 键的当前状态。Gets the current state of the SHIFT, CTRL, and ALT keys. |
方法
Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |