Control.QueryContinueDrag 이벤트

정의

끌어서 놓기 작업 중에 발생하며 끌기 소스가 끌어서 놓기 작업을 취소해야 할지를 결정하도록 합니다.

public:
 event System::Windows::Forms::QueryContinueDragEventHandler ^ QueryContinueDrag;
public event System.Windows.Forms.QueryContinueDragEventHandler QueryContinueDrag;
public event System.Windows.Forms.QueryContinueDragEventHandler? QueryContinueDrag;
member this.QueryContinueDrag : System.Windows.Forms.QueryContinueDragEventHandler 
Public Custom Event QueryContinueDrag As QueryContinueDragEventHandler 

이벤트 유형

예제

이 코드 발췌에서는 끌어서 놓기 작업이 폼의 범위를 벗어나는 경우 이벤트를 사용하여 QueryContinueDrag 끌어서 놓기 작업을 취소하는 방법을 보여 줍니다. 참조 된 DoDragDrop 전체 코드 예제에 대 한 메서드.

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 이벤트는 끌어서 놓기 작업 중 키보드 또는 마우스 단추 상태가 변경 될 때 발생 합니다. QueryContinueDrag 이벤트 끌기 소스가 끌어서 놓기 작업을 취소 해야 하는지 여부를 결정할 수 있습니다.

다음에서는 끌어서 놓기 작업이 발생하는 방식 및 시기에 대해 설명합니다.

메서드는 DoDragDrop 현재 커서 위치 아래의 컨트롤을 결정합니다. 그런 다음 컨트롤이 유효한 놓기 대상인지 확인합니다.

컨트롤이 유효한 놓기 대상인 GiveFeedback 경우 끌어서 놓기 효과가 지정된 상태에서 이벤트가 발생합니다. 끌어서 놓기 작업 결과 목록에 대한 자세한 내용은 DragDropEffects 열거형을 참조하십시오.

마우스 커서 위치, 키보드 상태 및 마우스 단추 상태의 변경 내용을 추적합니다.

  • 사용자가 창의 외부로 이동하면 DragLeave 이벤트가 발생합니다.

  • 마우스를 다른 컨트롤로 가져가면 해당 컨트롤에 대한 DragEnter가 발생합니다.

  • 마우스를 동일한 컨트롤 내에서 이동하면 DragOver 이벤트가 발생합니다.

키보드 또는 마우스 단추 상태가 QueryContinueDrag 변경되면 이벤트가 발생하고 끌기를 계속할지, 데이터를 삭제할지 또는 이벤트의 QueryContinueDragEventArgs속성 값 Action 에 따라 작업을 취소할지 결정합니다.

  • DragActionContinueDragOver 이면 작업을 계속 GiveFeedback 하기 위해 이벤트가 발생하고 이벤트가 새 효과와 함께 발생하므로 적절한 시각적 피드백을 설정할 수 있습니다. 유효한 끌어서 놓기 작업 결과 목록에 대한 자세한 내용은 DragDropEffects 열거형을 참조하십시오.

    참고

    DragOverGiveFeedback 이벤트는 마우스가 놓기 대상을 가로질러 이동할 때 사용자에게 마우스 위치에 대한 최신 피드백이 제공되도록 페어링됩니다.

  • 경우 값 DragActionDrop놓기 결과 값이 소스로 반환은, 원본 애플리케이션은 원본 데이터에 대해 적절 한 작업을 수행할 수 있도록 예의 경우 데이터 잘라내기 작업이 이동 합니다.

  • DragActionCancelDragLeave 이 이면 이벤트가 발생합니다.

기본적으로 QueryContinueDrag 이벤트는 ESC 키를 누른 경우 를 로 DragAction 설정하고 CancelAction 왼쪽, 가운데 또는 오른쪽 마우스 단추를 누르면 에서 DragAction 로 설정합니다 ActionDrop.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보