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
;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
This post has been edited by MikeOsdx: 20 March 2009 - 04:16 PM

Sign In
Register
Help

MultiQuote