stoyan 1 Posted September 29, 2010 (edited) Hello, all!I've got a list view control. It has to accepts a drag/dropped files from the Explorer. Then I have to filter them out and populate the list view. The problem is that list view does not file any event in on event mode. At least on my side. The closest thing I found on the forums is this answer. A slightly modified (on message) version is working ok, at least events are being fired. Here is the working (edited from the post above) script:#include <GUIConstants.au3> #include <WindowsConstants.au3> $parent = GUICreate("test",200,200,-1,-1,-1,$WS_EX_ACCEPTFILES) GUICtrlCreateListView("Test",10,10,75,75) GuiCtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState() Do $msg = GUIGetMsg() if $msg = $GUI_EVENT_DROPPED then MsgBox(0,"Test",@GUI_DROPID & " " & @GUI_DRAGFILE) endif Until $msg = $GUI_EVENT_CLOSE GuiDelete($parent)Here is the nonworking mine script:expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt('GUIOnEventMode', 1) Global Const $title = 'Some descriptive title' Global $treff main() while 1 sleep(5000) wend func main() $treff = GUICreate($title, 500, 385, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, 'handle_close') GUICtrlCreateListView('Column one|Column two', 10, 10, 480, 190, $LVS_NOSORTHEADER) GuiCtrlSetState(-1, $GUI_DROPACCEPTED) GuiCtrlSetOnEvent(-1, 'file_list_event_handler') GUISetState() EndFunc Func handle_close() Switch @GUI_WINHANDLE Case $treff Exit EndSwitch EndFunc Func file_list_event_handler() MsgBox(48, 'Event status', 'The event has fired!') EndFuncI'll need your support.Edit: fixed the link to the other post Edited September 29, 2010 by stoyan ; Opt('MustDeclareVars', 1) Share this post Link to post Share on other sites
kaotkbliss 146 Posted September 29, 2010 (edited) I had the same problem with listview drag/drop and Opt('GUIOnEventMode') I think it simply does not work with that combination. Your best bet is to use GuiGetMsg and find a way to trigger the functions you need that way. I know While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_DROPPED ListView_Add() Case $GUI_EVENT_SECONDARYDOWN $extrax = 2 $extray = 2 $wpos = WinGetPos($ver) $mpos = MouseGetPos() $ipos = ControlGetPos($ver, "", $ListView) If $mpos[0] > $wpos[0] + $ipos[0] + $extrax And $mpos[1] > $wpos[1] + $ipos[1] + $extray And $mpos[0] < $wpos[0] + $ipos[0] + $extrax + $ipos[2] And $mpos[1] < $wpos[1] + $ipos[1] + $extray + $ipos[3] Then ListView_RightClick() EndIf Case $GUI_EVENT_PRIMARYDOWN $extrax = 2 $extray = 2 $wpos = WinGetPos($ver) $mpos = MouseGetPos() $ipos = ControlGetPos($ver, "", $ListView) If $mpos[0] > $wpos[0] + $ipos[0] + $extrax And $mpos[1] > $wpos[1] + $ipos[1] + $extray And $mpos[0] < $wpos[0] + $ipos[0] + $extrax + $ipos[2] And $mpos[1] < $wpos[1] + $ipos[1] + $extray + $ipos[3] Then If TimerDiff($t) <= 500 And $q = 1 Then ListView_DblClick() Else $t = TimerInit() $q = 1 EndIf ElseIf $mpos[0] > $wpos[0] + $extrax And $mpos[1] > $wpos[1] + $extray And $mpos[0] < $wpos[0] + $ipos[0] + $extrax + $ipos[2] And $mpos[1] < $wpos[1] + $ipos[1] + $extray + $ipos[3] Then While _IsPressed(01) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) WEnd EndIf EndSwitch WEnd Worked in my script *edit* This snippit uses drag/drop, right click and double click. Edited September 29, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
taietel 34 Posted September 29, 2010 (edited) stoyan, I've modified a little your script, to handle the drop event: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Opt('GUIOnEventMode', 1) Global Const $title = 'Some descriptive title' Global $treff, $hLv,$iLV=0 main() while 1 sleep(5000) wend func main() $treff = GUICreate($title, 500, 385, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetOnEvent($GUI_EVENT_CLOSE, 'handle_close') $hLv = GUICtrlCreateListView('Column one|Column two', 10, 10, 480, 190, $LVS_NOSORTHEADER) GuiCtrlSetState(-1, $GUI_DROPACCEPTED) GuiSetOnEvent($GUI_EVENT_DROPPED, 'file_list_event_handler') GUISetState() EndFunc Func handle_close() Switch @GUI_WINHANDLE Case $treff Exit EndSwitch EndFunc Func file_list_event_handler() Local $nbv = @GUI_DRAGFILE $iLV +=1 GUICtrlCreateListViewItem($iLV&"|"&$nbv,$hLv) ;MsgBox(48, 'Event status', 'The event has fired!') EndFunc M.I. Edited September 29, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero...Progs:Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Share this post Link to post Share on other sites
kaotkbliss 146 Posted September 29, 2010 Guess I was wrong Maybe it was something else then that was blocking the drag/drop, but removing the "oneventmode" worked so I figured that was the problem. 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
taietel 34 Posted September 29, 2010 kaotkbliss, I've also tried before, but failed. Now, after I saw these posts, I've solved also my problem! Things you should know first...In the beginning there was only ONE! And zero...Progs:Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Share this post Link to post Share on other sites
stoyan 1 Posted September 29, 2010 Ahaa! Listen for the event on the window level. Thank you!May be this bugreport has something in common. АlthoughI couldn't find the mentioned passage in the documentation. ; Opt('MustDeclareVars', 1) Share this post Link to post Share on other sites
stoyan 1 Posted September 29, 2010 Nope, the bug report has nothing incommon with this case. Thank you all for the help. ; Opt('MustDeclareVars', 1) Share this post Link to post Share on other sites