How to disable drag/drop when a dialog box is open

前端 未结 1 1035
情书的邮戳
情书的邮戳 2021-01-18 15:35

I am working on a large application and am adding some drag/drop functionality to it. Specifically, I am allowing the user to drag and drop a file into the main window to o

相关标签:
1条回答
  • 2021-01-18 16:07

    I'm not sure how things work in C#, so let me know if this answer is incorrect. In C++ MFC, the main window is disabled when a dialog is displayed. You can test to see if the main window is disabled and ignore the drop if so.

    private void MyDragDrop(object sender, DragEventArgs e) {
        if (CanFocus)
            MessageBox.Show("dropped");
    }
    private void MyDragEnter(object sender, DragEventArgs e) {
        if (CanFocus)
            e.Effect = DragDropEffects.Copy;
        else
            e.Effect = DragDropEffects.None;
    } 
    
    0 讨论(0)
提交回复
热议问题