pedrit0 Posted February 2, 2011 Share Posted February 2, 2011 Hi allIf I drag and drop a file from an explorer window to a "Shell.Explorer.2" object that is created within a form : it worksIf I try the same drag and drop to a "Shell.Explorer.2" object that is created within a tab : it does NOT workI tested it under Windows 7 and Windows XP as administrator : same behaviour on both systemsMy problem can be understood with the following example code where you can see 2 "Shell.Explorer.2" objects. One is directly created in the form while the other one is created within a tab.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $oIE, $oIE2, $GUIActiveX1, $GUIActiveX2 Local $msg $oIE = ObjCreate("Shell.Explorer.2") $oIE2 = ObjCreate("Shell.Explorer.2") GUICreate("Embedded Web control Test", 570, 470, 0, 0, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN)) $TabSet = GUICtrlCreateTab(10, 50, 550, 220, 0) $TabSheet1 = GUICtrlCreateTabItem("test") $GUIActiveX1 = GUICtrlCreateObj ($oIE, 20, 100, 525, 150) $GUIActiveX2 = GUICtrlCreateObj ($oIE2, 20, 280, 525, 150) GUISetState() $oIE.navigate("c:\") $oIE2.navigate("c:\windows") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc I am almost sure this is a not a bug : I think I am missing something (required style or extended style or whatever), but cannot find what.Can you help me to open my eyes :-)thx a lot.Pedrit0 Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne. Link to comment Share on other sites More sharing options...
DaveRedford Posted February 6, 2011 Share Posted February 6, 2011 Hi, I tried this code and it dragged/dropped files both ways. Seemed to work fine. This looks like a similar problem to one I am trying to solve though.Have a look at and see if that will work for you.Cheers,Dave Link to comment Share on other sites More sharing options...
pedrit0 Posted February 7, 2011 Author Share Posted February 7, 2011 Hi, I tried this code and it dragged/dropped files both ways. Seemed to work fine. This looks like a similar problem to one I am trying to solve though. Have a look at and see if that will work for you. Hi Dave, and thx for your reply. I tried your code and it works for me. But anyway, when i insert a tab within your gui, drag and drop is disabled within the tab. I modified your code (see below) in order to show you the issue : Can you drag and drop some file from an external explorer window to the left drop zone of your GUI ? expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> ;used in the capture of mouse/key press $dll = DllOpen("user32.dll") $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler global $objMyComp=ObjCreate("shell.explorer.2") global $objMyDocs=ObjCreate("shell.explorer.2") global $MyCompURL="" global $MyDocsURL="" $main=GUICreate("Patient Access PC",@DesktopWidth-100, @DesktopHeight-100) $TabSet = GUICtrlCreateTab(10, 20, 650, 650, 0) GUICtrlCreateTabItem("") ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $TabSheet1 = GUICtrlCreateTabItem("TEST") GUICtrlSetState(-1,$GUI_SHOW) ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $btn_Logout = GUICtrlCreateButton("Log Out", 50, 50, 60, 30) $btn_rfsh_MyComp = GUICtrlCreateButton("Refresh", 150, 150, 60, 30) $btn_rfsh_MyDocs = GUICtrlCreateButton("Refresh", 850, 150, 60, 30) $btn_rst_MyDocs = GUICtrlCreateButton("Reset", 150,100,60,30) $btn_back_MyDocs = GUICtrlCreateButton("Back", 350,100,60,30) $btn_fwd_MyDocs = GUICtrlCreateButton("Forward", 350,150,60,30) $btn_back_MyComp = GUICtrlCreateButton("Back", 1050,100,60,30) $btn_fwd_MyComp = GUICtrlCreateButton("Forward", 1050,150,60,30) $lbl_MyComp_URL = GUICtrlCreateLabel("Location:",820,640,350,20) $lbl_MyDocs_URL = GUICtrlCreateLabel("Location:",120,640,350,20) $IEbed=GUICtrlCreateobj ($objMyDocs,10,10, @DesktopWidth-30,@DesktopHeight-60) $IEbed2=GUICtrlCreateobj ($objMyComp,10,10, @DesktopWidth-30,@DesktopHeight-60) With $objMyComp .Navigate("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") .left=800 .top=200 .height=400 .width=400 .menubar=0 .toolbar=0 .statusBar=0 .visible=1 EndWith With $objMyDocs .Navigate("::{450D8FBA-AD25-11D0-98A8-0800361B1103}") .left=100 .top=200 .height=400 .width=400 .menubar=0 .toolbar=0 .statusBar=0 .visible=1 EndWith GUISetState() ;A nice way to wait for windows to load $objMyComp.navigate("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") $objMyDocs.navigate("::{450D8FBA-AD25-11D0-98A8-0800361B1103}") ProgressOn("Creating Window", "Window Creation", "0 percent") For $i = 10 to 100 step 10 sleep(30) ProgressSet( $i, $i & " percent") Next ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() While 1 $loc=mousegetpos() ;if click in window 1 then refresh window 2 if $loc[0]>100 and $loc[0] <500 then ;get x width between 100 and 500 if $loc[1]>200 and $loc[1] < 600 then ;get y pos between 200 and 600 if _ispressed(01,$dll) Then call ("CleanURL") EndIf EndIf EndIf ;if click in window 2 then refresh window 1 if $loc[0]>800 and $loc[0] <1200 then ;get x width between 800 and 1200 if $loc[1]>200 and $loc[1] < 600 then ;get y pos between 200 and 600 if _ispressed(01,$dll) Then call ("CleanURL") EndIf EndIf EndIf ;check gui for selections $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $btn_rfsh_MyComp $objMyDocs.refresh case $msg = $btn_rfsh_MyDocs $objMyComp.refresh case $msg = $btn_rst_MyDocs $objMyComp.navigate("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") $objMyDocs.navigate("::{450D8FBA-AD25-11D0-98A8-0800361B1103}") ProgressOn("Rest", "Reseting Windows", "0 percent") For $i = 10 to 100 step 10 sleep(30) ProgressSet( $i, $i & " percent") Next ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() call("CleanURL") Case $msg = $btn_Logout ExitLoop case $msg = $btn_back_MyDocs $objMyDocs.goback call ("CleanURL") case $msg = $btn_fwd_MyDocs $objMyDocs.goforward call ("CleanURL") case $msg = $btn_back_MyComp $objMyComp.goback call ("CleanURL") case $msg = $btn_fwd_MyComp $objMyComp.goforward call ("CleanURL") EndSelect WEnd ;Clean the URL Func CleanURL () ;Clean My Computer $MyCompURL = StringReplace($objMyComp.LocationURL,"file:///","") $MyCompURL = StringReplace($MyCompURL,"/","\") $MyCompURL = StringReplace($MyCompURL,"%20"," ") guictrlsetdata($lbl_MyComp_URL, "Location:"& $MyCompURL) ;Clean My Docs $MyDocsURL = StringReplace($objMyDocs.LocationURL,"file:///","") $MyDocsURL = StringReplace($MyDocsURL,"/","\") $MyDocsURL = StringReplace($MyDocsURL,"%20"," ") $MyDocsURL = StringReplace($MyDocsURL,"C:\Documents and Settings\" & @USERNAME & "\","") guictrlsetdata($lbl_MyDocs_URL, "Location:"& $MyDocsURL) $objMyComp.refresh $objMyDocs.refresh EndFunc ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) ;if $HexNumber = "80020009" then msgbox(0,"Error","You cannot go do that at this time") $g_eventerror = 1 ; something to check for when this function returns Endfunc DllClose($dll) $main = 0 GUIDelete () Exit Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne. Link to comment Share on other sites More sharing options...
DaveRedford Posted February 9, 2011 Share Posted February 9, 2011 I tried it and you're right. I can't drag and drop into the Tab window but I can drag and drop out of it. Strange. I only ever wanted to be able to drag and drop between the two windows. Could you not set the right pane to be where you need to transfer files between or does it need to be a tab window and be able to drag and drop to external windows? Link to comment Share on other sites More sharing options...
pedrit0 Posted February 11, 2011 Author Share Posted February 11, 2011 Hi Dave, now u understand my issue ... The matter is that I cannot add a second explorer pane. In my dev, users must drag and drop files from an external explorer window... HEEELLPPPPPP... If ever someone from the AutoIT dev team read this post, I need HEEELLPPPPP Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne. Link to comment Share on other sites More sharing options...
rover Posted February 12, 2011 Share Posted February 12, 2011 Hi all If I drag and drop a file from an explorer window to a "Shell.Explorer.2" object that is created within a form : it works If I try the same drag and drop to a "Shell.Explorer.2" object that is created within a tab : it does NOT work Pedrit0 It looks like the behind the scenes code for handling AutoIt native controls on Tabs (showing/hiding) is interfering with D&D Placing the embedded explorer object on a Tab child dialog 'property sheet' with the main gui as parent, resolves this issue. As the embedded object native control is no longer directly on the tab, there are three issues to deal with. 1 - A WM_NCPAINT message handler for repainting of the embedded control on restore from minimize or showing/hidding form. 2 - A WM_NOTIFY/TCN_SELCHANGE message handler to Show/Hide child dialog, as non-native controls/child windows are not automatically shown or hidden with Tab change. Optional: 3 - A WM_NCHITTEST message handler is required to lock the child dialog in place. In order to support tabbing between controls, WS_EX_CONTROLPARENT extended style is required. Note: Because of an issue with the WS_EX_CONTROLPARENT extended style allowing the child window to be moveable, a WM_NCHITTEST message handler is required to lock it in place. In this example, the child dialog and the explorer object are the same size, so the gui cannot be dragged. It is your choice then to use or remove, I would recommend leaving it in if you use WS_EX_CONTROLPARENT. see Trac ticket #1115 for the reason this style has the side effect of making an AutoIt class child gui draggable. Ticket #1115 (closed Bug: No Bug) documentation for GuiCreate error http://www.autoitscript.com/trac/autoit/ticket/1115 There is an unresolved issue with tabbing not working between the two explorer windows. Maybe placing the second explorer object on a child gui would fix this. Both explorer windows GUICtrlCreateObj() containers have WS_TABSTOP and WS_EX_CONTROLPARENT styles, so I don't know what would resolve this without looking into it further. You need to refresh the listview of the embedded explorer windows when files are dropped, maybe in a WM_NCACTIVATE handler. expandcollapse popup;embedded shell object on Tab child dialog ;fix for drag and drop from external window issue. ;example by Pedrit0 ;modified by rover 2k11 Opt("MustDeclareVars", 1) #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> Global Const $TCN_FIRST = -550 Global Const $TCN_SELCHANGE = ($TCN_FIRST - 1) Global $hForm_Child, $TabSet Example() Func Example() Local $oIE, $oIE2, $GUIActiveX1, $GUIActiveX2 Local $msg, $hMain $oIE = ObjCreate("Shell.Explorer.2") $oIE2 = ObjCreate("Shell.Explorer.2") $hMain = GUICreate("Embedded Web control Test", 570, 470, 0, 0, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) $hForm_Child = GUICreate("", 525, 150, 20, 100, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $hMain) $GUIActiveX1 = GUICtrlCreateObj($oIE, 0, 0, 525, 150) GUISetState(@SW_SHOW) ; Go back to main GUI GUISwitch($hMain) $TabSet = GUICtrlCreateTab(10, 50, 550, 220, 0) Local $TabSheet1 = GUICtrlCreateTabItem("test") GUICtrlCreateTabItem(""); end tabitem definition Local $TabSheet2 = GUICtrlCreateTabItem("test2") GUICtrlCreateTabItem(""); end tabitem definition $GUIActiveX2 = GUICtrlCreateObj($oIE2, 20, 280, 525, 150) GUIRegisterMsg($WM_NCHITTEST, "_WM_HANDLER") GUIRegisterMsg($WM_NOTIFY, "_WM_HANDLER") GUIRegisterMsg($WM_NCPAINT, "_WM_HANDLER") GUIRegisterMsg($WM_NCACTIVATE, "_WM_HANDLER") GUISetState() $oIE.navigate("c:\") $oIE2.navigate("c:\windows") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc ;==>Example Func _WM_HANDLER($hWnd, $iMsg, $iwParam, $ilParam) #forceref $iMsg, $iwParam, $ilParam Switch $iMsg Case $WM_NCPAINT ;Required to refresh the embedded explorer object after a change to the window and then a restore from minimize or form hidden/shown. _WinAPI_RedrawWindow($hForm_Child, 0, 0, $RDW_UPDATENOW) Case $WM_NCHITTEST ;Prevents tab child dialog $hForm_Child with WS_EX_CONTROLPARENT style from moving If Number($hWnd) = Number($hForm_Child) Then Return 1 Case $WM_NOTIFY ;Show/Hide child dialog on Tab 0 Local $tNMHDR = DllStructCreate("hwnd hWndFrom;uint_ptr IDFrom;INT Code", $ilParam);$tagNMHDR ;$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom;$hWndFrom Case $TabSet;$hWndTab Switch $iCode Case $TCN_SELCHANGE GUICtrlRead($TabSet) If GUICtrlRead($TabSet) = 0 Then GUISetState(@SW_SHOW, $hForm_Child) Else GUISetState(@SW_HIDE, $hForm_Child) EndIf EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HANDLER I see fascists... Link to comment Share on other sites More sharing options...
pedrit0 Posted February 14, 2011 Author Share Posted February 14, 2011 Rover, It works : thank u very much... U saved me I could not imagine such a solution. Big up to you skills on the gui part of AutoIT, you are the Pedrit0 Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now