QueryContinueDragEventHandler 대리자

정의

QueryContinueDragControl 이벤트를 처리할 메서드를 나타냅니다.

public delegate void QueryContinueDragEventHandler(System::Object ^ sender, QueryContinueDragEventArgs ^ e);
public delegate void QueryContinueDragEventHandler(object sender, QueryContinueDragEventArgs e);
public delegate void QueryContinueDragEventHandler(object? sender, QueryContinueDragEventArgs e);
type QueryContinueDragEventHandler = delegate of obj * QueryContinueDragEventArgs -> unit
Public Delegate Sub QueryContinueDragEventHandler(sender As Object, e As QueryContinueDragEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
QueryContinueDragEventArgs

이벤트 데이터를 포함하는 QueryContinueDragEventArgs입니다.

예제

다음 예제에서는 두는 끌어서 놓기 작업을 보여 줍니다. ListBox 컨트롤입니다. 예제에서는 호출을 DoDragDrop 끌기 작업이 시작 될 때 메서드. 마우스를 이동 하는 경우 끌기 작업이 시작 둘 SystemInformation.DragSize 하는 동안 마우스 위치에서의 MouseDown 이벤트입니다. 합니다 IndexFromPoint 메서드를 사용 하는 동안 끌어서 항목의 인덱스를 확인 합니다 MouseDown 이벤트입니다.

또한이 사용자 지정 커서를 사용 하 여 끌어서 놓기 작업에 대 한 예제입니다. 이 예제에서는 두 개의 가정 커서 파일인 3dwarro.cur3dwno.cur, 사용자 지정 끌기에 대 한 애플리케이션 디렉터리에 있으며 놓기 없음 커서를 각각. 사용자 지정 커서를 사용할 경우는 UseCustomCursorsCheckCheckBox 확인란이 선택 되어 있습니다. 에 설정 된 사용자 지정 커서를 GiveFeedback 이벤트 처리기입니다.

키보드 상태에서 평가 되는 DragOver 오른쪽에 대 한 이벤트 처리기 ListBox결정 끌기 작업을 SHIFT, CTRL, ALT 또는 CTRL + ALT 키의 상태에 따라 합니다. 위치는 ListBox 하는 동안 결정 됩니다 드롭다운 수행 되는 DragOver 이벤트입니다. 데이터 삭제 없는 경우는 String, 해당 DragEventArgs.Effect 로 설정 된 DragDropEffects.None합니다. 드롭다운의 상태에 표시 됩니다는 마지막으로, 합니다 DropLocationLabelLabel합니다.

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

이 코드 예제를 사용 하 여 보여 줍니다.는 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

설명

QueryContinueDragEventHandler 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 대리자를 사용 하 여 이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보