"Drag and Drop" noch möglich ?

04/07/2013 17:53 Croco™#1
Hi,
ich versuche gerade eine GUI zu erstellen auf die man eine Datei ziehen kann.
Nur leider klappt es mit keinem bis jetzt gefundenen Script. Was habe ich falsch gemacht ?

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 490, 301, -1,-1,-1,0x00000018)
GUISetIcon("icon.ico", -1)
$ListView1 = GUICtrlCreateListView("Skin", 0, 0, 312, 300, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, -2)
$ListView1_0 = GUICtrlCreateListViewItem("Test", $ListView1)
$Group1 = GUICtrlCreateGroup("Drop new Skins her", 316, 4, 169, 109)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Löschen", 316, 116, 167, 25)
$Button2 = GUICtrlCreateButton("Speichern", 316, 144, 167, 25)
$Label1 = GUICtrlCreateLabel("", 320, 172, 46, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $GUI_EVENT_DROPPED
			 MsgBox(4096, "drag drop file", @GUI_DRAGFILE)
	EndSwitch
WEnd
04/07/2013 18:00 Achat#2
Beispiel:

Code:
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=arrow.ico
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=epvpImg Uploader
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Field=Compile Date|%date% %time%
#AutoIt3Wrapper_Res_Field=AutoItVersion|%autoitver%
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

#region ### START Koda GUI section ### Form=C
Global $FormEPVPIMG = GUICreate("FormEPVPIMG", 445, 192, 197, 130, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetTip(-1, "Drag && Drop images here... ")
#endregion ### END Koda GUI section ###

Global $aDropFiles[1]

GUICtrlCreateLabel('', 0, 0, 368, 173)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetBkColor(0xFFFFFF)

GUISetState(@SW_SHOW)

If IsAdmin() Then ; Allow to receive this messages if run elevated
	_ChangeWindowMessageFilterEx($FormEPVPIMG, 0x233, 1) ; $WM_DROPFILES
	_ChangeWindowMessageFilterEx($FormEPVPIMG, $WM_COPYDATA, 1) ; redundant?
	_ChangeWindowMessageFilterEx($FormEPVPIMG, 0x0049, 1) ; $WM_COPYGLOBALDATA
EndIf

GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $GUI_EVENT_DROPPED
				_ArrayDisplay($aDropFiles)
	EndSwitch
WEnd

Func _ChangeWindowMessageFilterEx($hWnd, $iMsg, $iAction) ; http://www.autoitscript.com/forum/topic/124406-drag-and-drop-with-uac/#entry864050
	Local $aCall = DllCall("user32.dll", "bool", "ChangeWindowMessageFilterEx", _
			"hwnd", $hWnd, _
			"dword", $iMsg, _
			"dword", $iAction, _
			"ptr", 0)
	If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
	Return 1
EndFunc   ;==>_ChangeWindowMessageFilterEx

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 $aDropFiles[$i + 1]
		$aDropFiles[$i] = DllStructGetData($pFileName, 1)
		$pFileName = 0
	Next
EndFunc   ;==>WM_DROPFILES_FUNC
Multidrop geht auch.

MfG
04/07/2013 18:03 Croco™#3
Hat sich da etwas in den Jahren verändert ?
Ich habe ältere Scripte die alle nicht mehr gehen !?
04/07/2013 18:05 Achat#4
Ka, aber wenn du dein Script mit Adminrechten startest, brauchst du diese Zusatzfunktionen, [Only registered and activated users can see links. Click Here To Register...] damit es funktioniert (sind in meinem Script enthalten).

MfG
04/07/2013 18:07 Croco™#5
Wie immer ist verlass auf dich ;)
Danke