다음을 통해 공유


QueryContinueDragEventArgs 클래스

QueryContinueDrag 이벤트에 대한 데이터를 제공합니다.

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

구문

‘선언
<ComVisibleAttribute(True)> _
Public Class QueryContinueDragEventArgs
    Inherits EventArgs
‘사용 방법
Dim instance As QueryContinueDragEventArgs
[ComVisibleAttribute(true)] 
public class QueryContinueDragEventArgs : EventArgs
[ComVisibleAttribute(true)] 
public ref class QueryContinueDragEventArgs : public EventArgs
/** @attribute ComVisibleAttribute(true) */ 
public class QueryContinueDragEventArgs extends EventArgs
ComVisibleAttribute(true) 
public class QueryContinueDragEventArgs extends EventArgs

설명

QueryContinueDrag 이벤트는 끌어서 놓기 작업 중에 발생하여 끌기 소스가 끌어서 놓기 작업을 취소해야 할지 여부를 결정하도록 합니다. QueryContinueDragEventArgs는 끌어서 놓기 작업의 진행 여부 및 방법, 보조키 또는 Esc 키가 눌러져 있는지 여부를 지정합니다.

기본적으로 Esc 키를 누른 경우 QueryContinueDrag 이벤트는 ActionDragAction.Cancel로 설정하고 마우스 왼쪽, 가운데 또는 오른쪽 단추를 누른 경우 ActionDragAction.Drop으로 설정합니다.

이벤트 모델에 대한 자세한 내용은 이벤트 및 대리자를 참조하십시오.

예제

다음 코드 예제에서는 두 개의 ListBox 컨트롤 간에 수행되는 끌어서 놓기 작업을 보여 줍니다. 다음 예제에서는 끌기가 시작될 때 DoDragDrop 메서드가 호출됩니다. MouseDown 이벤트가 발생하는 동안 마우스 위치로부터 SystemInformation.DragSize 이상 마우스를 이동하면 끌기 작업이 시작됩니다. IndexFromPoint 메서드는 MouseDown 이벤트가 발생하는 동안 끌어 올 항목의 인덱스를 확인하는 데 사용됩니다.

또한 다음 예제에서는 끌어서 놓기 작업에 대해 사용자 지정 커서를 사용하는 방법을 보여 줍니다. 다음 예제에서는 두 커서 파일, 즉 사용자 지정 끌기 커서와 놓기 못함 커서에 대한 3dwarro.cur3dwno.cur가 각각 응용 프로그램 디렉터리에 있는 것으로 가정합니다. UseCustomCursorsCheckCheckBox를 선택하면 사용자 지정 커서가 사용됩니다. 사용자 지정 커서는 GiveFeedback 이벤트 처리기에서 설정됩니다.

Shift, Ctrl, Alt 또는 Ctrl+Alt 중 끌기 작업을 수행하는 데 사용할 키 상태를 결정하기 위해 ListBoxDragOver 이벤트 처리기에서 키보드 상태가 확인됩니다. DragOver 이벤트가 수행되는 동안 ListBox에서 끌어 놓기가 발생한 위치도 확인됩니다. 끌 데이터가 String이 아니면 DragEventArgs.EffectDragDropEffects.None으로 설정됩니다. 마지막으로, 끌어 놓기 상태가 DropLocationLabelLabel에 표시됩니다.

오른쪽 ListBox에 놓을 데이터는 DragDrop 이벤트 처리기에서 결정되며 String 값은 ListBox의 적절한 위치에 추가됩니다. 끌기 작업이 폼의 범위를 벗어나면 QueryContinueDrag 이벤트 처리기에서 끌어서 놓기 작업이 취소됩니다.

인용된 이 코드에서는 QueryContinueDragEventArgs 클래스를 QueryContinueDrag 이벤트와 함께 사용하는 방법을 보여 줍니다. 전체 코드 예제를 보려면 DoDragDrop 메서드를 참조하십시오.

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, System.Windows.Forms.ListBox)

    If Not (lb is 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
private void ListDragSource_QueryContinueDrag(object sender, System.Windows.Forms.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;
        }
    }
}
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, 
    System.Windows.Forms.QueryContinueDragEventArgs e)
{
    // Cancel the drag if the mouse moves off the form.
    ListBox lb = (ListBox)sender;

    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.get_MousePosition().get_X() - screenOffset.get_X() 
            < f.get_DesktopBounds().get_Left() 
            || Control.get_MousePosition().get_X() 
            - screenOffset.get_X() > f.get_DesktopBounds().get_Right() 
            || Control.get_MousePosition().get_Y() - screenOffset.get_Y() 
            < f.get_DesktopBounds().get_Top() 
            || Control.get_MousePosition().get_Y() - screenOffset.get_Y() 
            > f.get_DesktopBounds().get_Bottom()) {
            e.set_Action(DragAction.Cancel);
        }
    }
} //listDragSource_QueryContinueDrag

상속 계층 구조

System.Object
   System.EventArgs
    System.Windows.Forms.QueryContinueDragEventArgs

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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에서 지원

참고 항목

참조

QueryContinueDragEventArgs 멤버
System.Windows.Forms 네임스페이스
DragAction 열거형
DoDragDrop