2012/08/10(Fri) 12:09:36 編集(投稿者)
■No63281 (ブータン さん) に返信
ドロップ時に時間がかかるときBeginInvokeでDragDropをすぐ終了し
処理を遅延実行させる例
Private m_dragTarget As String = Nothing
Private SyncInvoke As IAsyncResult
Private Sub Label1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop
If Not e.Data.GetDataPresent("FileName") Then Exit Sub
m_dragTarget = CType(e.Data.GetData("FileName"), String())(0)
SyncInvoke = Label1.BeginInvoke(New Action(AddressOf DragDropMain))
End Sub
Private Sub DragDropMain()
Dim dlgFile As New OpenFileDialog()
If dlgFile.ShowDialog = Windows.Forms.DialogResult.OK Then
Label1.Text = m_dragTarget
Label2.Text = dlgFile.FileName
End If
m_dragTarget = Nothing
End Sub
Private Sub Label1_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Label1.DragEnter
If e.Data.GetDataPresent("FileName") Then
e.Effect = DragDropEffects.Copy
End If
End Sub