找回密码
 加入
搜索
楼主: cykefu

[AU3基础] 怎么把多个窗口,集成在一个大窗口中

 火.. [复制链接]
发表于 2011-11-19 05:03:04 | 显示全部楼层
功能可能达到了,不过貌似很容易出问题,可能和while嵌套有关,不建议多层while内部嵌套
 楼主| 发表于 2011-11-19 06:27:14 | 显示全部楼层
能不能把多个IE窗口,缩小,排列在一个大窗口中。
发表于 2011-11-19 20:20:05 | 显示全部楼层
牛X啊,这样也可以,佩服
发表于 2011-11-20 17:18:17 | 显示全部楼层
楼主表达的意思不明啊.....
发表于 2011-11-20 17:52:01 | 显示全部楼层
回复 16# netegg

是不是改成这样比较好?
#include <Timers.au3>

$Gui = GUICreate("Gui_1")
$Button_1 = GUICtrlCreateButton("Button1", 10, 30, 100)


$Gui_2 = GUICreate("Gui_2", 150, 150, -1, -1, -1, -1, $Gui)
$Button_2 = GUICtrlCreateButton("Button2", 10, 30, 50)

GUISetState(@SW_SHOW, $Gui)

While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = -3
                        _Timer_KillAllTimers($Gui_2)
                        If WinGetState($Gui_2) = 5 Then
                                ExitLoop
                        Else
                                GUISetState(@SW_HIDE, $Gui_2)
                        EndIf
                Case $msg = $Button_1
                        $TimerDLL = _Timer_SetTimer($Gui_2, 10, "Opos")
                        GUISetState(@SW_SHOW, $Gui_2)
        EndSelect
WEnd

Func Opos($hWnd, $uiMsg, $idEvent, $dwTime)
        $CursorInfo = GUIGetCursorInfo()
        If $idEvent = $TimerDLL Then
                If WinExists($Gui_2) Then
                        Local $MainWindow = WinGetPos($Gui)
                        Local $SubWindow = WinGetPos($Gui_2)
                        WinMove($Gui_2, "", $MainWindow[0] + ($MainWindow[2] / 2) - ($SubWindow[2] / 2), _
                                        $MainWindow[1] + ($MainWindow[3] / 2) - ($SubWindow[3] / 2))
                EndIf
        EndIf
EndFunc   ;==>Opos
发表于 2011-11-20 19:52:39 | 显示全部楼层
给你个官方的例子
[au3]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <misc.au3>

Opt("GuiOnEventMode",1)
Opt("MustDeclareVars",1)

Global $HWNDMAIN, $GUI_W = 800, $GUI_H = 600
Global $HWNDCHILD, $Child_W = 600, $Child_H = 400
Global $activePackage = 0, $activeChildren[1] = [0], $GUI_CTRLID = 0

$HWNDMAIN = GUICreate("Main", $GUI_W, $GUI_H, Default, Default)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUISetState()

$HWNDCHILD = GUICreate("",$Child_W,$Child_H,100, 100, BitOR($WS_POPUP,$WS_BORDER),$WS_EX_MDICHILD,$HWNDMAIN)
GUISetBkColor(0xFFFFBB)
GUISetState()
$activePackage = $HWNDCHILD ;Simulates something from full script
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")

_CreateCell($HWNDCHILD, 136, 142 )
_CreateCell($HWNDCHILD, 136, 142 )



While 1
    Sleep(250)
WEnd


Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)

    ConsoleWrite("WM_WINDOWPOSCHANGING" & @CRLF)

        Local $i, $activeCell = 0
        For $i = 1 to $activeChildren[0]
            If $hWnd = $activeChildren[$i] then
                $activeCell = $HWND
                ConsoleWrite($activeCell & @CRLF)
                ExitLoop
            EndIf
        Next

    If WinActive($HWNDMAIN) then Return
    If $hWnd <> $activeCell then Return
    If $activePackage = 0 then Return

    Local $aMain_Pos = WinGetPos($activePackage) ;Get the position of the ParentCell
    If NOT IsArray($aMain_Pos) then Return

    Local $aCell_Pos = WinGetPos($HWND) ;<< patch
    If NOT IsArray($aCell_Pos) then Return


            ;Get the position of the window which is currently dragging and specify the drag limits
            Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)
            Local $iLeft = DllStructGetData($stWinPos, 3)
            Local $iTop = DllStructGetData($stWinPos, 4)
            Local $iWidth = $aCell_Pos[2] ;<< patch DllStructGetData($stWinPos, 5)
            Local $iHeight = $aCell_Pos[3] ;<< patch DllStructGetData($stWinPos, 6)

            If DllStructGetData($stWinPos, 5) <> $iWidth then DllStructSetData($stWinPos, 5, $iWidth)
            If DllStructGetData($stWinPos, 6) <> $iHeight then DllStructSetData($stWinPos, 6, $iHeight)

            Local $iX_Min = $aMain_Pos[0]
            Local $iY_Min = $aMain_Pos[1]
            Local $iX_Max = ($aMain_Pos[0] + $aMain_Pos[2]) - $iWidth
            Local $iY_Max = ($aMain_Pos[1] + $aMain_Pos[3]) - $iHeight


            ConsoleWrite("X = " & $iLeft & @CRLF & _
                        "Y = " & $iTop & @CRLF & _
                        "W = " & $iWidth & @CRLF & _
                        "H = " & $iHeight & @crlf)


            If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min)

            If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max)

            If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min)

            If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max)



    Return $GUI_RUNDEFMSG

EndFunc


Func _CreateCell($vHWND, $w,$h )


    Local $HWNDCHILD = GUICreate("",$w, $h, 1, 1, BitOR($WS_POPUP,$WS_BORDER),$WS_EX_MDICHILD,$vHWND)
    GUICtrlCreatePic(@ProgramFilesDir & "\AutoIt3\Examples\GUI\Merlin.gif",0,0,$w,$h, $WS_CLIPSIBLINGS ,$GUI_WS_EX_PARENTDRAG)
    GUICtrlCreateLabel("",0,0,$w,$h,Default,$GUI_WS_EX_PARENTDRAG)
    GUICtrlSetOnEvent(-1,"_MouseClick")
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    GUISetState()
    ReDim $activeChildren[$activeChildren[0] +2]
    $activeChildren[$activeChildren[0] +1] = $HWNDCHILD
    $activeChildren[0] +=1

    Return $HWNDCHILD

EndFunc

Func _MouseClick()

    $GUI_CTRLID = @GUI_CtrlId

EndFunc


Func _Exit()
    Exit
EndFunc[/au3]

评分

参与人数 1金钱 +10 贡献 +5 收起 理由
lixiaolong + 10 + 5 谢谢!

查看全部评分

 楼主| 发表于 2011-12-1 18:14:17 | 显示全部楼层
谢谢,非常感谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 16:39 , Processed in 0.074671 second(s), 17 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表