找回密码
 加入
搜索
查看: 2103|回复: 9

[GUI管理] 【已解决】关于窗口层次的设置

[复制链接]
发表于 2020-2-18 00:41:54 | 显示全部楼层 |阅读模式
本帖最后由 anythinging 于 2020-2-18 17:09 编辑

正在努力学习窗口层次中,遇到一个问题,恳请各位大神指点,谢谢!求指点$ form1始终在最下层,不遮挡$ form2,$ form3的方法,谢谢!
#include <ButtonConstants.au3>
#include < GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include <WinAPISysWin.au3>

$ Form1 = GUICreate(“ Form1”,1800,1000,-1,-1,$ WS_POPUP)
GUICtrlCreatePic(' back01.jpg',-1,-1,1800,1000)
$ Label1 = GUICtrlCreateLabel(“ Label1” ,160,200,132,33)$
Button1 = GUICtrlCreateButton(“ Button1”,
24,16,65,33 )GUISetBkColor (0x444444)

$ Form2 = GUICreate(“ Form2”,600,80,-1,-1,$ WS_POPUP,$ WS_EX_TOPMOST)
$ Button3 = GUICtrlCreateButton(“ 333”,24,16,65,33)
GUISetBkColor(0xABCDEF)
GUISetState(@SW_SHOW)

$ Form3 = GUICreate(“ Form3”,300,200,300,-1,$ WS_POPUP,$ WS_EX_LAYERED)
GUISetBkColor(0x363636)
_WinAPI_SetLayeredWindowAttributes($ Form3,0x363636)
$ Button5 = GUICtrlCreateButton(“ 555”,24,16,65 , 33)
GUISetState(@SW_SHOW)

While 1
        $ nMsg = GUIGetMsg()
        开关$ nMsg
                情况$ GUI_EVENT_CLOSE
                        退出
       EndSwitch
WEnd

发表于 2020-2-18 09:38:29 | 显示全部楼层

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
;#include <WinAPISysWin.au3>
Global $iWidtha = @DesktopWidth
Global $iHeighta = @DesktopHeight
$Form1 = GUICreate("Form1", $iWidtha - 48, $iHeighta - 130, -1, -1, $WS_POPUP)
GUICtrlCreatePic('back01.jpg', -1, -1, 1800, 1000)
$Label1 = GUICtrlCreateLabel("Label1", 160, 200, 132, 33)
GUICtrlSetFont(-1, 24, 600, 0, 'Arial');"微软雅黑")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, -2)
GUICtrlSetCursor(-1, 0)
$Button1 = GUICtrlCreateButton("退出", 24, 16, 65, 33)
;GUISetBkColor(0x444444)

$Form2 = GUICreate("Form2", 900, 80, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Button3 = GUICtrlCreateButton("333", 24, 16, 65, 33)
GUISetBkColor(0xABCDEF)


$Form3 = GUICreate("Form3", 300, 80, 492, 124, $WS_POPUP, $WS_EX_TOPMOST);,$WS_EX_LAYERED)
GUISetBkColor(0xA1BFAA - 0x440000);GUISetBkColor(0x363636)
_WinAPI_SetLayeredWindowAttributes($Form3, 0x363636)
$Button5 = GUICtrlCreateButton("555", 24, 16, 65, 33)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_SHOW, $Form3)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button1
                        Exit
        EndSwitch
WEnd
 楼主| 发表于 2020-2-18 09:52:19 | 显示全部楼层
chzj589 发表于 2020-2-18 09:38
[au3]
#include
#include

感谢回复!您这个是将form3设置成置顶了,我想实现form3不是像form2那样置顶(即可以被其它窗口遮挡),form1始终在最底层,类似在桌面,即最底层。
查了资料好象要用到_WinAPI_SetParent($Form1, $hParent),但没效果。
 楼主| 发表于 2020-2-18 09:53:31 | 显示全部楼层
本帖最后由 anythinging 于 2020-2-18 09:58 编辑

感觉需要对Form1进行操作,将其设置为最底层或者是桌面。我想实现
form1最底层,(相当于背景)
form2始终是最上层,
form3是透明,普通窗口(相当于中间层)


尝试使用
$hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]')
_WinAPI_SetParent($Form1, $hParent)
即form1设置为桌面的子窗口,未能成功。
发表于 2020-2-18 10:23:58 | 显示全部楼层
anythinging 发表于 2020-2-18 09:53
感觉需要对Form1进行操作,将其设置为最底层或者是桌面。我想实现
form1最底层,(相当于背景)
form2始 ...

是这个意思?



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2020-2-18 10:26:33 | 显示全部楼层
搞定了,3层目前基本掌握。底层,中层,顶层
 楼主| 发表于 2020-2-18 10:28:44 | 显示全部楼层

是的,底form1,中form2,顶form3
 楼主| 发表于 2020-2-18 10:30:12 | 显示全部楼层
这个是正确的,搞定。
 楼主| 发表于 2020-2-18 10:32:55 | 显示全部楼层
本帖最后由 anythinging 于 2020-2-18 10:36 编辑

这个是正确的。3层窗口层次。底,中,顶,还有一个问题,就是如果增加form4,即底form1,
顶,form2
中上,form3
中下,form4
的话,是否就是简单的调整form3,form4的顺序?
又有了一个疑问,是否可以用_WinAPI_SetParent($Form4, $Form3)来实现?测试中
#include <GUIConstantsEx.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>


Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]')
Local $Form1 = GUICreate('form1', @DesktopWidth,@DesktopHeight, 0, 0,$WS_POPUP);,$WS_POPUP
_WinAPI_SetParent($Form1, $hParent)
GUICtrlCreatePic('back01.jpg',0,0,@DesktopWidth,@DesktopHeight)
GUISetState(@SW_SHOWNOACTIVATE)



$Form2 = GUICreate("Form2", 900, 80, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Button3 = GUICtrlCreateButton("333", 24, 16, 65, 33)
GUISetBkColor(0xABCDEF)


$Form3 = GUICreate("Form3", 300, 200, 300, -1,$WS_POPUP,$WS_EX_LAYERED)
GUISetBkColor(0x363636)
_WinAPI_SetLayeredWindowAttributes($Form3, 0x363636)
$Button5 = GUICtrlCreateButton("555", 24, 16, 65, 33)



GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_SHOW, $Form3)



Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
发表于 2020-2-18 21:51:26 | 显示全部楼层
anythinging 发表于 2020-2-18 10:32
这个是正确的。3层窗口层次。底,中,顶,还有一个问题,就是如果增加form4,即底form1,
顶,form2
中上, ...

我的图片






本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 22:40 , Processed in 0.082726 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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