[已解决]如何让子窗口跟随父窗口移动
本帖最后由 a62105400 于 2010-11-29 18:23 编辑即开了子窗口后,移动父窗口子窗口在父窗口的位子不变 ,跟着移动??
求助各位大婶 本帖最后由 afan 于 2009-8-12 21:33 编辑
呵呵,这里大婶可能稀有...
http://www.autoitx.com/forum.php?mod=viewthread&tid=2624 #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 100, 100, 242, 174)
GUISetState(@SW_SHOW)
$Form2 = GUICreate("Form2", 294, 164, 192, 124)
GUISetState(@SW_SHOW)
While 1
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
If $XY2 <> $XY Or $XY2 <> $XY Then
WinMove($Form1, "", $XY2+50, $XY2+50)
WinSetOnTop('Form1','',1)
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
楼上两位think you very much $Form2 = GUICreate("Form2", 294, 164, 192, 124,"","",$Form1) 为什么不重写WM_SIZE消息?每次循环都设置一次浪费性能…… 为什么不重写WM_SIZE消息?每次循环都设置一次浪费性能……
78391493 发表于 2010-7-16 18:10 http://www.autoitx.com/images/common/back.gif
楼上不妨写个例子和大家分享下 LS写个例子和大家分享下... 过来学习的。。顺便帮LZ顶上 #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 100, 100, 242, 174)
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUIRegisterMsg($WM_SIZE, "MY_MOVE")
GUISetState(@SW_SHOW)
$Form2 = GUICreate("Form2", 294, 164, 192, 124)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
$XY = WinGetPos($Form1)
$XY2 = WinGetPos($Form2)
WinMove($Form1, "", $XY2+50, $XY2+50)
WinSetOnTop('Form1','',1)
EndFunc
MY_MOVE()呢? MY_MOVE()是干什么的呢? 学习中。很有启发 值得学习。呵呵 记号上,认真学习
页:
[1]
2