找回密码
 加入
搜索
查看: 3801|回复: 8

[GUI管理] 【已解决】怎么取父窗口的坐标建立子窗口?

  [复制链接]
发表于 2011-3-8 00:38:51 | 显示全部楼层 |阅读模式
本帖最后由 qq82015930 于 2011-3-9 13:58 编辑

怎么取父窗口的坐标建立子窗口

就是父窗口不管移动到什么位置,点击出来的子窗口都在父窗口的中间.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 442, 265, 192, 114)
$Button1 = GUICtrlCreateButton("Button1", 8, 0, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GUISetState(@SW_DISABLE, $Form1) 
                       $Form2 = GUICreate('子窗口', 200, 200, -1, -1, $Form1)   ;这点的-1, -1, 是取父窗口$Form1的中心位置
                        WinSetOnTop("子窗口", "", 1)     
                        $Button22 = GUICtrlCreateButton("确定", 50, 80, 100, 30, 0) 
                        GUISetState() 
        EndSwitch
WEnd
 

要点击$Button1 才出来第二个窗口 第一个窗口不管移到什么位置在点$Button1第二个窗口都会是在第一个窗口的中间不是镶入第一个GUI,是面上.
发表于 2011-3-8 01:16:19 | 显示全部楼层
创建子窗口的函数中最后参数加上父参数的句柄
 楼主| 发表于 2011-3-8 12:51:24 | 显示全部楼层
创建子窗口的函数中最后参数加上父参数的句柄
happytc 发表于 2011-3-8 01:16



    能否举个列子.
发表于 2011-3-8 13:06:10 | 显示全部楼层

$hwd = GUICreate("Parent", 100, 100, 10, 10)
GUISetState()
$Pos = WinGetPos($hwd)
GUICreate("child",$Pos[2]/2,$Pos[3]/2,($Pos[0] + $Pos[2])/2, ($Pos[1] + $Pos[3])/2, -1,-1,$hwd)
GUISetState()
While 1
        Sleep(100)
WEnd
 楼主| 发表于 2011-3-8 16:50:42 | 显示全部楼层
happytc 发表于 2011-3-8 13:06



    谢谢~~~
我要的,是$Form2 = GUICreate('子窗口', 200, 200, -1, -1, $Form1)   ;这点的-1, -1, 是取父窗口$Form1的中心位置
发表于 2011-3-8 17:23:02 | 显示全部楼层
回复 5# qq82015930
怎么不知道变通呢?
$hwd = GUICreate("Parent", 400, 300, 10, 10)
GUISetState()
$Pos = WinGetPos($hwd)
GUICreate("child",200,200,$Pos[2]/2, $Pos[3]/2, 0x80880000,0x00000040 ,$hwd)
GUISetState()

While GUIGetMsg()<>-3
        Sleep(10)
WEnd
Exit
 楼主| 发表于 2011-3-9 13:36:42 | 显示全部楼层
回复  qq82015930
怎么不知道变通呢?
3mile 发表于 2011-3-8 17:23



    我不是要这样的,是要点击$Button1 才出来第二个窗口 第一个窗口不管移到什么位置在点$Button1第二个窗口都会是在第一个窗口的中间
 楼主| 发表于 2011-3-9 13:58:40 | 显示全部楼层
回复  qq82015930
怎么不知道变通呢?
3mile 发表于 2011-3-8 17:23



    谢谢,已经解决拉.
发表于 2016-9-20 16:59:32 | 显示全部楼层
回复 8# qq82015930


    问下楼主,怎么解决的,分享下!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 11:22 , Processed in 0.077970 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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