DragAction 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
끌어서 놓기 작업을 계속하는 방법과 경우를 지정합니다.
public enum class DragAction
[System.Runtime.InteropServices.ComVisible(true)]
public enum DragAction
public enum DragAction
[<System.Runtime.InteropServices.ComVisible(true)>]
type DragAction =
type DragAction =
Public Enum DragAction
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| Continue | 0 | 작업이 계속됩니다. |
| Drop | 1 | 작업이 삭제되면 중지됩니다. |
| Cancel | 2 | 삭제 메시지 없이 작업이 취소됩니다. |
예제
다음 예제에서는 두 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.
오른쪽 ListBox 에 대해 삭제할 데이터는 이벤트 처리기에서 DragDrop 결정되며 String 값은 해당 위치에 추가됩니다 ListBox. 끌기 작업이 폼의 범위를 벗어나면 이벤트 처리기에서 QueryContinueDrag 끌어서 놓기 작업이 취소됩니다.
이 코드 발췌에서는 열거형을 사용하는 방법을 DragAction 보여 줍니다. 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
설명
이 열거형은 QueryContinueDragEventArgs에서 사용됩니다.