AutoIt Forums: Explorer GUI Dock problem - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Explorer GUI Dock problem Moving Explorer Win does not move docked GUI

#1 User is offline   MikeOsdx 

  • Never trust a Monkey
  • PipPipPipPip
  • Group: Full Members
  • Posts: 529
  • Joined: 12-April 04
  • Location:New York

Posted 20 March 2009 - 04:07 PM

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

[ code='text' ]    ( 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

This post has been edited by MikeOsdx: 20 March 2009 - 04:16 PM

0

#2 User is offline   Dolemite50 

  • Advanced Member
  • PipPip
  • Group: Full Members
  • Posts: 137
  • Joined: 10-January 07

Posted 04 November 2009 - 01:54 AM

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. :)
0

#3 User is offline   Melba23 

  • Yes, me!
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,055
  • Joined: 01-August 08
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted 04 November 2009 - 09:58 AM

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
0

#4 User is offline   Melba23 

  • Yes, me!
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,055
  • Joined: 01-August 08
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted 04 November 2009 - 04:53 PM

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 ( :huggles: ). 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 ( :ph34r: ) can explain that.
[ autoIt ]    ( 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
0

#5 User is offline   martin 

  • ~~\o/~~~/0\=¬''~~~
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 5,712
  • Joined: 24-October 04
  • Location:uk

Posted 04 November 2009 - 06:40 PM

View PostMelba23, on 04 November 2009 - 03:53 PM, said:

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 ( :huggles: ). 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 ( :ph34r: ) can explain that.
[ autoIt ]    ( 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.
[ code='text' ]    ( 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  

0

#6 User is offline   Melba23 

  • Yes, me!
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,055
  • Joined: 01-August 08
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted 04 November 2009 - 06:50 PM

MikeOsdx,

Another little improvement - if you move the explorer side and then immediately try resizing, it works (after a fashion!).
[ autoIt ]    ( 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! :blink:

M23

P.S. I like martin's approach - will it meet your requirements?

This post has been edited by Melba23: 04 November 2009 - 06:55 PM

0

#7 User is offline   PsaltyDS 

  • Most Venerable Penguin
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 9,706
  • Joined: 12-December 05
  • Location:Victoria Crater, Mars

Posted 04 November 2009 - 08:47 PM

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:
[ code='text' ]    ( 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.

:)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users