I was wondering if there was anyway to get the file address of a file before it was actually dropped, e.g. when the cursor is holding the file over the form but has no let go of it yet. Thanks in advance. The code below is what I have so far and it works fine for normal dropping.
Code:Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements IMessageFilter.PreFilterMessage If m.Msg = WM_DROPFILES Then Dim nfiles As Integer = DragQueryFile(m.WParam, -1, Nothing, 0) '<- this code to handle multiple dropped files.. not really neccesary for this example Dim i As Integer For i = 0 To nfiles Dim sb As StringBuilder = New StringBuilder(256) DragQueryFile(m.WParam, i, sb, 256) HandleDroppedFiles(sb.ToString()) Next DragFinish(m.WParam) Return True End If Return False End Function Public Sub HandleDroppedFiles(ByVal file As String) If Len(file) > 0 Then MsgBox("File has been dropped") End If End Sub Private Declare Function DragAcceptFiles Lib "shell32.dll" (ByVal hwnd As IntPtr, ByVal accept As Boolean) As Long Private Declare Function DragQueryFile Lib "shell32.dll" (ByVal hdrop As IntPtr, ByVal ifile As Integer, ByVal fname As StringBuilder, ByVal fnsize As Integer) As Integer Private Declare Sub DragFinish Lib "Shell32.dll" (ByVal hdrop As IntPtr) Public Const WM_DROPFILES As Integer = 563




Reply With Quote