Control.QueryContinueDrag 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
끌어서 놓기 작업 중에 발생하며 끌기 소스에서 끌어서 놓기 작업을 취소해야 하는지 여부를 결정할 수 있습니다.
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 에 따라 작업을 취소할지를 결정합니다.
값 DragAction 이면
ContinueDragOver 작업을 GiveFeedback 계속하기 위해 이벤트가 발생하고 적절한 시각적 피드백을 설정할 수 있도록 새 효과와 함께 이벤트가 발생합니다. 유효한 드롭 효과 목록은 열거형을 DragDropEffects 참조하세요.메모
마우스가 DragOver 놓기 대상을 가로질러 이동하면 사용자에게 마우스 위치에 대한 가장 up-to날짜 피드백이 제공되도록 이벤트와 GiveFeedback 이벤트가 쌍으로 연결됩니다.
값 DragAction 이면 원본 애플리케이션이
Drop원본 데이터에 대해 적절한 작업을 수행할 수 있도록 놓기 효과 값이 원본에 반환됩니다. 예를 들어 작업이 이동인 경우 데이터를 잘라냅니다.값 DragAction 이
CancelDragLeave 면 이벤트가 발생합니다.
기본적으로 QueryContinueDrag 이벤트는 ESC 키를 누른 경우 in DragAction 으로 Cancel 설정하고 Action 왼쪽, 가운데 또는 오른쪽 마우스 단추를 누르면 in으로 설정합니다 DropActionDragAction.
이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생시키기를 참조하십시오.