au3那么多函数,你就不会跟踪第一个窗口的坐标?下面是修改的,现在就是移动第2个窗口,第一个也能在第二个的位置打开。
#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("第一个窗体", 440, 243, 193, 125)
$LabelA1 = GUICtrlCreateLabel("第一个窗体", 112, 64, 64, 17)
$ButtonA1 = GUICtrlCreateButton("打开2", 96, 160, 75, 25, 0)
$ButtonA2 = GUICtrlCreateButton("退出", 256, 160, 75, 25, 0)
$Form2 = GUICreate("第二个窗体", 440, 243, 193, 125)
$LabelB1 = GUICtrlCreateLabel("第二个窗体", 112, 64, 64, 17)
$ButtonB1 = GUICtrlCreateButton("返回1", 96, 160, 75, 25, 0)
$ButtonB2 = GUICtrlCreateButton("退出", 256, 160, 75, 25, 0)
GUISwitch($Form1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg[0]
Case $GUI_EVENT_CLOSE
Switch $nMsg[1]
Case $Form1
Exit
Case $Form2
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
If $XY2[0] <> $XY[0] Or $XY2[1] <> $XY[1] Then
WinMove($Form1, "", $XY2[0], $XY2[1])
EndIf
_Open_Close_Form($Form1, $Form2)
EndSwitch
Case $ButtonA1
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
If $XY2[0] <> $XY[0] Or $XY2[1] <> $XY[1] Then
WinMove($Form2, "", $XY[0], $XY[1])
EndIf
_Open_Close_Form($Form2, $Form1)
Case $ButtonA2
Exit
Case $ButtonB1
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
If $XY2[0] <> $XY[0] Or $XY2[1] <> $XY[1] Then
WinMove($Form1, "", $XY2[0], $XY2[1])
EndIf
_Open_Close_Form($Form1, $Form2)
Case $ButtonB2
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
If $XY2[0] <> $XY[0] Or $XY2[1] <> $XY[1] Then
WinMove($Form1, "", $XY2[0], $XY2[1])
EndIf
_Open_Close_Form($Form1, $Form2)
EndSwitch
WEnd
Func _Open_Close_Form($OForm, $CForm)
GUISwitch($OForm)
GUISetState(@SW_SHOW)
GUISwitch($CForm)
GUISetState(@SW_HIDE)
EndFunc ;==>_Open_Close_Form
[ 本帖最后由 顽固不化 于 2008-8-4 11:56 编辑 ] |