Jump to content

Multiple file drag...


Recommended Posts

Here is some code I stripped out of a Phillips MP3 manager I made, Is this what you are after?

#Include <GuiConstants.au3>
#Include <GuiListView.au3>




Global $gaDropFiles[1]
Global Const $WM_DROPFILES = 0x233

$Form1 = GUICreate("Philips SA260 Manager", 633, 467, -1, -1,-1,BitOr($WS_EX_ACCEPTFILES,$WS_EX_DLGMODALFRAME))


;Main listview which accepts droped items
$ListView1 = GUICtrlCreateListView("Files", 152, 54, 473, 300,-1)
_GUICtrlListViewSetColumnWidth ( -1, 0, 400)
GUICtrlSetState($ListView1, $GUI_DROPACCEPTED)
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $GUI_EVENT_DROPPED
            
                    $str = ""
                    For $i = 0 To UBound($gaDropFiles) - 1
                        GuiCtrlCreateListViewItem($gaDropFiles[$i],$ListView1)
                    Next

    EndSwitch
    
    
WEnd



Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
        
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc
Link to comment
Share on other sites

Here is some code I stripped out of a Phillips MP3 manager I made, Is this what you are after?

#Include <GuiConstants.au3>
#Include <GuiListView.au3>
Global $gaDropFiles[1]
Global Const $WM_DROPFILES = 0x233

$Form1 = GUICreate("Philips SA260 Manager", 633, 467, -1, -1,-1,BitOr($WS_EX_ACCEPTFILES,$WS_EX_DLGMODALFRAME))
;Main listview which accepts droped items
$ListView1 = GUICtrlCreateListView("Files", 152, 54, 473, 300,-1)
_GUICtrlListViewSetColumnWidth ( -1, 0, 400)
GUICtrlSetState($ListView1, $GUI_DROPACCEPTED)
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $GUI_EVENT_DROPPED
            
                    $str = ""
                    For $i = 0 To UBound($gaDropFiles) - 1
                        GuiCtrlCreateListViewItem($gaDropFiles[$i],$ListView1)
                    Next

    EndSwitch
    
    
WEnd
Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
        
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc
AWESOME! Thanks!
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...