BigDaddyO Posted March 20, 2009 Posted March 20, 2009 (edited) I am writing up a little program that will allow users to drag and drop files and folders into a list to assist with data migrations. I have been trying many many different methods to display the Directory strucutre and have settled with Docking an explorer windows to my GUI. I am using the code from GAFrost with his Code Snippet and if I move the GUI the Windows Explorer window stays with it perfect, but when I move the Explorer window my GUI does not move with it. Anybody have any ideas? Current Full code is below Thanks, Mike edit: updated so it will recognize Explorer in WinXP expandcollapse popup;Resize from AutoIT GUI on top works but not when resizing from bottom ;Move and Resize does not work from Windows Explorer windows #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", 4) $iWidth = 320 $iHeight = 460 $x2 = (@DesktopWidth - ($iWidth * 2)) / 2 $y2 = (@DesktopHeight - $iHeight) / 2 ;Create the GUI Window $hGUI = GUICreate("Migration Assistant", $iWidth, $iHeight, -1, -1, $WS_SIZEBOX) GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17) GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 45) ;Launch Windows Explorer at the My Comptuer Level $hWin2 = Run("Explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", @SystemDir, @SW_HIDE) ;Wait until the explorer window has launched ;Get the handle of that window so it can be used later if @OSVersion = "WIN_XP" or @OSVersion = "WIN_2000" Then if WinWait("Classname=ExploreWClass", "", 45) = 0 then Exit $hExplorer = WinGetHandle("Classname=CabinetWClass", "") Else if WinWait("Classname=CabinetWClass", "", 45) = 0 then Exit $hExplorer = WinGetHandle("Classname=CabinetWClass", "") EndIf WinMove($hExplorer, "", $x2, $y2, $iWidth, $iHeight) ;Identify the position of the AutoIT GUI $WinPos = WinGetPos($hGUI) $x1 = $WinPos[0] $y1 = $WinPos[1] ;Tells the _KeepWindowsDocked function to perform the initial doc $Dock = 2 ;Dock the windows now _KeepWindowsDocked($hExplorer, $hGUI, $Dock, $x1, $x2, $y1, $y2) ;Register resize/move events GUIRegisterMsg($WM_MOVE, "_WinMoved") GUIRegisterMsg($WM_SIZE, "_WinMoved") ;Display the GUI Window GUISetState () WinSetState($hExplorer, "", @SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ;CLose the Explorer window also WinClose($hExplorer) Exit EndIf WEnd Func _KeepWindowsDocked(ByRef $GUI1, ByRef $GUI2, ByRef $Dock, ByRef $x1, ByRef $x2, ByRef $y1, ByRef $y2) Local $p_win1 = WinGetPos($GUI1) Local $p_win2 = WinGetPos($GUI2) If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Or $Dock = 2) Then $x1 = $p_win1[0] $y1 = $p_win1[1] $x2 = $p_win1[2] + $x1 $y2 = $y1 WinMove($GUI2, "", $x2, $y2, $p_Win2[2], $p_Win1[3]) $Dock = 1 ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2)) Then $x2 = $p_win2[0] $y2 = $p_win2[1] $x1 = $p_win2[0] - $p_win1[2] $y1 = $y2 WinMove($GUI1, "", $x1, $y1, $p_Win1[2], $p_Win2[3]) ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 16) Then WinSetState($GUI2, "", @SW_MINIMIZE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 16) Then WinSetState($GUI1, "", @SW_MINIMIZE) ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Then WinSetState($GUI2, "", @SW_RESTORE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2) Then WinSetState($GUI1, "", @SW_RESTORE) EndIf EndFunc ;==>_KeepWindowsDocked Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam If ($hWndGUI = $hGUI) Or ($hWndGUI = $hExplorer) Then _KeepWindowsDocked($hExplorer, $hGUI, $Dock, $x1, $x2, $y1, $y2) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WinMoved Edited March 20, 2009 by MikeOsdx
Dolemite50 Posted November 4, 2009 Posted November 4, 2009 I haven't tried troubleshooting your problem but you might consider making them both children of a main GUI. SmokeN has an example of embedding two explorer controls GUI around here somewhere, it should be in the ballpark. Sorry if that doesn't help, good luck.
Moderators Melba23 Posted November 4, 2009 Moderators Posted November 4, 2009 MikeOsdx,The script is not working becasue the Explorer window is not firing your _WinMoved function - I imagine because it is not an AutoIt GUI and so you cannot intercept the mesage via GUIRegisterMsg.Perhaps if you tried embedding the Explorer window in your own GUI, whose message you could intercept. I am afraid I do not have time to try this at present - perhaps later today. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted November 4, 2009 Moderators Posted November 4, 2009 MikeOsdx, Ok, here is where I have got to for the moment. This script produces as embedded Explorer on the left and your Migration GUI on the right. They now follow each other like 2 very good friends ( ). However, I have only been able to get the simultaneaous resize to work for the Migration GUI - perhaps because of the the embedded Explorer, I cannot get the lefthand GUI to take focus and hence accept any resize commands. And yet it fires the message for moving without any problems - perhaps someone with more experience of these dark matters ( ) can explain that. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 4) $iWidth = 320 $iHeight = 460 ;Create the GUI Window Global $hMigration = GUICreate("Migration Assistant", $iWidth, $iHeight, Default, Default, $WS_SIZEBOX) GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 60) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState () ;Identify the position of the AutoIT GUI $WinPos = WinGetPos($hMigration) Global $x1 = $WinPos[0] Global $y1 = $WinPos[1] ; Set Explorer GUI coords Global $x2 = $x1 - $iWidth Global $y2 = $y1 ; Create the Explorer GUI Global $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, $x2, $y2, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN, $WS_SIZEBOX)) GUISetState () Run("explorer.exe /n, M:\") ; Set it the folder you want as a start point WinWait("[CLASS:CabinetWClass]") Global $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") _WinAPI_SetParent($hExplorer, $hExplHolder) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) WinSetState($hExplorer, "", @SW_MAXIMIZE) ;Tell the _KeepWindowsDocked function to perform the initial dock Global $Dock = 2 ;Dock the windows now _KeepWindowsDocked($hMigration, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) ;Register messages GUIRegisterMsg($WM_MOVE, "_WinMoved") GUIRegisterMsg($WM_SIZE, "_WinMoved") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit EndIf ; Exit if Explorer window is shut If Not WinExists($hExplorer) Then Exit WEnd Func _KeepWindowsDocked($hWnd, $GUI1, $GUI2, $Dock, ByRef $x1, ByRef $x2, ByRef $y1, ByRef $y2) Local $p_win1 = WinGetPos($GUI1) Local $p_win2 = WinGetPos($GUI2) ; If Migration is active If $hWnd = $GUI1 Then ; If Migration has moved or has changed size If $p_win1[0] <> $x1 Or $p_win1[1] <> $y1 Or $p_win1[2] <> $p_win2[2] Or $p_win1[3] <> $p_win2[3] Then $x1 = $p_win1[0] $y1 = $p_win1[1] $x2 = $x1 - $p_win1[2] $y2 = $y1 WinMove($GUI2, "", $x2, $y2, $p_win1[2], $p_win1[3]) WinMove($hExplorer, "", 0,0, $p_win2[2], $p_Win2[3]) EndIf ElseIf $hWnd = $GUI2 Or $Dock = 2 Then If $p_win2[0] <> $x2 Or $p_win2[1] <> $y2 Then $x2 = $p_win2[0] $y2 = $p_win2[1] $x1 = $x2 + $p_win1[2] $y1 = $y2 WinMove($GUI1, "", $x1, $y1) $Dock = 1 EndIf ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 16) Then WinSetState($GUI2, "", @SW_MINIMIZE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 16) Then WinSetState($GUI1, "", @SW_MINIMIZE) ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Then WinSetState($GUI2, "", @SW_RESTORE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2) Then WinSetState($GUI1, "", @SW_RESTORE) EndIf EndFunc ;==>_KeepWindowsDocked Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam If ($hWndGUI = $hMigration) Or ($hWndGUI = $hExplHolder) Then _KeepWindowsDocked($hWndGUI, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WinMoved I hope that has gone some way to helping your project progress. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
martin Posted November 4, 2009 Posted November 4, 2009 MikeOsdx, Ok, here is where I have got to for the moment. This script produces as embedded Explorer on the left and your Migration GUI on the right. They now follow each other like 2 very good friends ( ). However, I have only been able to get the simultaneaous resize to work for the Migration GUI - perhaps because of the the embedded Explorer, I cannot get the lefthand GUI to take focus and hence accept any resize commands. And yet it fires the message for moving without any problems - perhaps someone with more experience of these dark matters ( ) can explain that. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 4) $iWidth = 320 $iHeight = 460 ;Create the GUI Window Global $hMigration = GUICreate("Migration Assistant", $iWidth, $iHeight, Default, Default, $WS_SIZEBOX) GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 60) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState () ;Identify the position of the AutoIT GUI $WinPos = WinGetPos($hMigration) Global $x1 = $WinPos[0] Global $y1 = $WinPos[1] ; Set Explorer GUI coords Global $x2 = $x1 - $iWidth Global $y2 = $y1 ; Create the Explorer GUI Global $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, $x2, $y2, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN, $WS_SIZEBOX)) GUISetState () Run("explorer.exe /n, M:\") ; Set it the folder you want as a start point WinWait("[CLASS:CabinetWClass]") Global $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") _WinAPI_SetParent($hExplorer, $hExplHolder) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) WinSetState($hExplorer, "", @SW_MAXIMIZE) ;Tell the _KeepWindowsDocked function to perform the initial dock Global $Dock = 2 ;Dock the windows now _KeepWindowsDocked($hMigration, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) ;Register messages GUIRegisterMsg($WM_MOVE, "_WinMoved") GUIRegisterMsg($WM_SIZE, "_WinMoved") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit EndIf ; Exit if Explorer window is shut If Not WinExists($hExplorer) Then Exit WEnd Func _KeepWindowsDocked($hWnd, $GUI1, $GUI2, $Dock, ByRef $x1, ByRef $x2, ByRef $y1, ByRef $y2) Local $p_win1 = WinGetPos($GUI1) Local $p_win2 = WinGetPos($GUI2) ; If Migration is active If $hWnd = $GUI1 Then ; If Migration has moved or has changed size If $p_win1[0] <> $x1 Or $p_win1[1] <> $y1 Or $p_win1[2] <> $p_win2[2] Or $p_win1[3] <> $p_win2[3] Then $x1 = $p_win1[0] $y1 = $p_win1[1] $x2 = $x1 - $p_win1[2] $y2 = $y1 WinMove($GUI2, "", $x2, $y2, $p_win1[2], $p_win1[3]) WinMove($hExplorer, "", 0,0, $p_win2[2], $p_Win2[3]) EndIf ElseIf $hWnd = $GUI2 Or $Dock = 2 Then If $p_win2[0] <> $x2 Or $p_win2[1] <> $y2 Then $x2 = $p_win2[0] $y2 = $p_win2[1] $x1 = $x2 + $p_win1[2] $y1 = $y2 WinMove($GUI1, "", $x1, $y1) $Dock = 1 EndIf ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 16) Then WinSetState($GUI2, "", @SW_MINIMIZE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 16) Then WinSetState($GUI1, "", @SW_MINIMIZE) ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Then WinSetState($GUI2, "", @SW_RESTORE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2) Then WinSetState($GUI1, "", @SW_RESTORE) EndIf EndFunc ;==>_KeepWindowsDocked Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam If ($hWndGUI = $hMigration) Or ($hWndGUI = $hExplHolder) Then _KeepWindowsDocked($hWndGUI, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WinMoved I hope that has gone some way to helping your project progress. M23 I don't know if this is an improvement but it looks a lot simpler to me. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 4) $iWidth = 320 $iHeight = 460 ;Create the GUI Window Global $hMigration = GUICreate("Migration Assistant", $iWidth*2, $iHeight, -1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPCHILDREN, $WS_SIZEBOX)) GUICtrlCreateLabel("Folders/Files to Migrate", $iWidth, 10, ($iWidth - 20), 17) GUICtrlSetResizing(-1, $GUI_DOCKTOP); + $GUI_DOCKTOP + $GUI_DOCKBOTTOM+ $GUI_DOCKRIGHT) GUICtrlCreateList("", $iWidth, 35, $iWidth - 2, $iHeight - 35) GUICtrlSetResizing(-1,$GUI_DOCKTOP + $GUI_DOCKBOTTOM); $GUI_DOCKBORDERS) GUISetState() Run("explorer.exe /n, C:\") ; Set it the folder you want as a start point WinWait("[CLASS:CabinetWClass]") Global $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") _WinAPI_SetParent($hExplorer, $hMigration) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) GUIRegisterMsg($WM_SIZE, "_WinMoved");so we can resize explorer While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _WinAPI_SetParent($hExplorer,0) WinClose($hExplorer) Exit EndIf ; Exit if Explorer window is shut If Not WinExists($hExplorer) Then Exit WEnd Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) Local $clientWid = BitAnd($lparam,0xffff) Local $clientHt = BitShift($lparam,16) WinMove($hExplorer,"",0,0,$clientWid/2,$clientHt) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Moderators Melba23 Posted November 4, 2009 Moderators Posted November 4, 2009 (edited) MikeOsdx, Another little improvement - if you move the explorer side and then immediately try resizing, it works (after a fashion!). expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 4) $iWidth = 320 $iHeight = 460 ;Create the GUI Window Global $hMigration = GUICreate("Migration Assistant", $iWidth, $iHeight, Default, Default, $WS_SIZEBOX) GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 60) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState () ;Identify the position of the AutoIT GUI $WinPos = WinGetPos($hMigration) Global $x1 = $WinPos[0] Global $y1 = $WinPos[1] ; Set Explorer GUI coords Global $x2 = $x1 - $iWidth Global $y2 = $y1 ; Create the Explorer GUI Global $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, $x2, $y2, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN, $WS_SIZEBOX)) GUISetState () Run("explorer.exe /n, M:\") ; Set it the folder you want as a start point WinWait("[CLASS:CabinetWClass]") Global $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") _WinAPI_SetParent($hExplorer, $hExplHolder) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) WinSetState($hExplorer, "", @SW_MAXIMIZE) ;Tell the _KeepWindowsDocked function to perform the initial dock Global $Dock = 2 ;Dock the windows now _KeepWindowsDocked($hMigration, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) ;Register messages GUIRegisterMsg($WM_MOVE, "_WinMoved") GUIRegisterMsg($WM_SIZE, "_WinMoved") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit EndIf ; Exit if Explorer window is shut If Not WinExists($hExplorer) Then Exit WEnd Func _KeepWindowsDocked($hWnd, $GUI1, $GUI2, $Dock, ByRef $x1, ByRef $x2, ByRef $y1, ByRef $y2) Local $p_win1 = WinGetPos($GUI1) Local $p_win2 = WinGetPos($GUI2) ; If Migration is active If $hWnd = $GUI1 Then ; If Migration has moved or has changed size If $p_win1[0] <> $x1 Or $p_win1[1] <> $y1 Or $p_win1[2] <> $p_win2[2] Or $p_win1[3] <> $p_win2[3] Then $x1 = $p_win1[0] $y1 = $p_win1[1] $x2 = $x1 - $p_win1[2] $y2 = $y1 WinMove($GUI2, "", $x2, $y2, $p_win1[2], $p_win1[3]) Local $c_win2 = WinGetClientSize($GUI2) WinMove($hExplorer, "", 0,0, $c_win2[0], $c_win2[1]) EndIf ElseIf $hWnd = $GUI2 Or $Dock = 2 Then If $p_win2[0] <> $x2 Or $p_win2[1] <> $y2 Or $p_win1[2] <> $p_win2[2] Or $p_win1[3] <> $p_win2[3] Then $x2 = $p_win2[0] $y2 = $p_win2[1] $x1 = $x2 + $p_win1[2] $y1 = $y2 WinMove($GUI1, "", $x1, $y1, $p_win2[2], $p_win2[3]) Local $c_win2 = WinGetClientSize($GUI2) WinMove($hExplorer, "", 0,0, $c_win2[0], $c_win2[1]) $Dock = 1 EndIf ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 16) Then WinSetState($GUI2, "", @SW_MINIMIZE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 16) Then WinSetState($GUI1, "", @SW_MINIMIZE) ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Then WinSetState($GUI2, "", @SW_RESTORE) ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2) Then WinSetState($GUI1, "", @SW_RESTORE) EndIf EndFunc ;==>_KeepWindowsDocked Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam, $lParam If ($hWndGUI = $hMigration) Or ($hWndGUI = $hExplHolder) Then If $hWndGUI = $hExplHolder Then WinSetState($hExplorer, "", @SW_DISABLE) _KeepWindowsDocked($hWndGUI, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2) WinSetState($hExplorer, "", @SW_ENABLE) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WinMoved That is it for today - I will try sleeping on it! M23 P.S. I like martin's approach - will it meet your requirements? Edited November 4, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
PsaltyDS Posted November 4, 2009 Posted November 4, 2009 I got interested and gave it a try. Trying to maintain right/left docking of two windows together, resize Explorer to match client area, and maintain Z-order of the other window when one is moved. Plus, with all the handles declared Global, I didn't see why so many things had to be passed to the function. All it really needs to know is which window moved: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "D:\" Global $iWidth = 320, $iHeight = 460 ; Create the (left) Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX)) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") _WinAPI_SetParent($hExplorer, $hExplHolder) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) WinSetState($hExplorer, "", @SW_MAXIMIZE) ; Create the (right) GUI Window $hMigration = GUICreate("Migration Assistant", $iWidth, $iHeight, Default, Default, $WS_SIZEBOX) GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 60) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) ; Show the GUIs GUISetState(@SW_SHOW, $hMigration) GUISetState(@SW_SHOW, $hExplHolder) _KeepWindowsDocked($hExplHolder) ;Register messages GUIRegisterMsg($WM_MOVE, "_WinMoved") GUIRegisterMsg($WM_SIZE, "_WinMoved") ConsoleWrite("Debug: $hExplHolder = " & $hExplHolder & @LF) ConsoleWrite("Debug: $hExplorer = " & $hExplorer & @LF) ConsoleWrite("Debug: $hMigration = " & $hMigration & @LF) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit EndIf ; Exit if Explorer window is shut If Not WinExists($hExplorer) Then Exit WEnd ; $hWnd = hwnd of window that changed (matches either $hExplHolder or $hMigration) ; Left ($hExplHolder) or Right ($hMigration) window will be docked to the one that changed ; If $hExplHolder changes, resize $hExplorer to fit client area Func _KeepWindowsDocked($hChanged) ConsoleWrite("Debug: _KeepWindowsDocked(" & $hChanged & ")" & @LF) Local $aPosExplHolder = WinGetPos($hExplHolder) Local $iStateExplHolder = WinGetState($hExplHolder) Local $aClientExplHolder = WinGetClientSize($hExplHolder) Local $aPosMigration = WinGetPos($hMigration) Local $iStateMigration = WinGetState($hMigration) ; Match state if neccessary If BitAND($iStateExplHolder, 16) <> BitAND($iStateMigration, 16) Then ; They don't match If $hChanged = $hExplHolder Then If BitAND($iStateExplHolder, 16) Then WinSetState($hMigration, "", @SW_MINIMIZE) Else WinSetState($hMigration, "", @SW_RESTORE) EndIf ElseIf $hChanged = $hMigration Then If BitAND($iStateMigration, 16) Then WinSetState($hExplHolder, "", @SW_MINIMIZE) Else WinSetState($hExplHolder, "", @SW_RESTORE) EndIf Else Return 0 EndIf Return 1 EndIf ; Match docked pos If $hChanged = $hExplHolder Then WinMove($hMigration, "", $aPosExplHolder[0] + $aPosExplHolder[2], $aPosExplHolder[1]) ; Move $hMigration to dock _WinAPI_SetWindowPos($hMigration, $hExplHolder, 0, 0, 0, 0, $SWP_NOMOVE + $SWP_NOSIZE) ; Set Z order WinMove($hExplorer, "", 0, 0, $aClientExplHolder[0], $aClientExplHolder[1]) ; Move $hExplorer to fit client area ElseIf $hChanged = $hMigration Then WinMove($hExplHolder, "", $aPosMigration[0] - $aPosExplHolder[2], $aPosMigration[1]) _WinAPI_SetWindowPos($hExplHolder, $hMigration, 0, 0, 0, 0, $SWP_NOMOVE + $SWP_NOSIZE) ; Set Z order Else Return 0 EndIf ; Done Return 1 EndFunc ;==>_KeepWindowsDocked Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam) If ($hWndGUI = $hMigration) Or ($hWndGUI = $hExplHolder) Then _KeepWindowsDocked($hWndGUI) Return $GUI_RUNDEFMSG EndFunc ;==>_WinMoved I don't even know if that's what was wanted, but it was an interesting exercise anyway. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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