找回密码
 加入
搜索
查看: 1893|回复: 3

[GUI管理] 透明GUI窗口,如何让边框不透明?【已解决】

[复制链接]
发表于 2018-3-10 13:53:35 | 显示全部楼层 |阅读模式
本帖最后由 fenhanxue 于 2018-3-10 21:34 编辑

想要这样一个GUI窗口:
1.透明
2.没有标题栏
3.可以鼠标拖拉改动大小
4.边框不透明(即可以看到边框)

下面的代码,1,2,3都可以实现,但是4无法实现,即按照下面的代码,我就完全看不到边框了
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>




$hGUI = GUICreate("透明",300,200,-1,-1,$WS_POPUP + $WS_SIZEBOX)

WinSetTrans($hGUI, "", 1);透明窗口(0-255)

GUISetState(@SW_SHOW)
HotKeySet('q','quit');退出快捷键

While 1
       Sleep(10)
WEnd
   
   
Func quit()
        Exit
EndFunc
 楼主| 发表于 2018-3-10 14:26:17 | 显示全部楼层
或者说,有没办法创建这样的窗体:


即红色部分为GUI,其他部分都不是GUI
鼠标可以直接点击非GUI部分

例如,图中,我可以鼠标直接点击软件(D:)就可以打开D盘

本帖子中包含更多资源

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

×
发表于 2018-3-10 16:39:07 | 显示全部楼层
回复 2# fenhanxue


    有自带例子的..

_WinAPI_SetLayeredWindowAttributes

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Local $hGui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")
Local $idLayButt = GUICtrlCreateButton("Button", 10, 40, 40)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGui, 0x010101)
GUISetState(@SW_SHOW)

Local $hGuicontrol = GUICreate("ControlGUI", 300, 400, 100, 100)
Local $idCheckTrans = GUICtrlCreateCheckbox("Transparent color 0xABCDEF (Checked) Or 0x010101", 10, 10)
Local $idCheckBorder = GUICtrlCreateCheckbox("POPUP-Style", 10, 30)
GUICtrlCreateLabel("Transparency for Layered GUI", 10, 50)
Local $idSlTrans = GUICtrlCreateSlider(10, 70, 200, 30)
GUICtrlSetLimit($idSlTrans, 255, 0)
GUICtrlSetData(-1, 255)
GUISetState(@SW_SHOW)

While 1
        Local $aExtMsg = GUIGetMsg(1)
        Local $iMsg = $aExtMsg[0]
        Switch $aExtMsg[1]
                Case $hGuicontrol
                        Select
                                Case $iMsg = $GUI_EVENT_CLOSE
                                        Exit
                                Case $iMsg = $idCheckTrans Or $iMsg = $idSlTrans

                                        ; Change Attributes of Trans-Color and Window Transparency

                                        If BitAND(GUICtrlRead($idCheckTrans), $GUI_CHECKED) = $GUI_CHECKED Then
                                                _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, GUICtrlRead($idSlTrans))
                                        Else
                                                _WinAPI_SetLayeredWindowAttributes($hGui, 0x010101, GUICtrlRead($idSlTrans))
                                        EndIf

                                Case $iMsg = $idCheckBorder
                                        If BitAND(GUICtrlRead($idCheckBorder), $GUI_CHECKED) = $GUI_CHECKED Then
                                                GUISetStyle($WS_POPUP, -1, $hGui)
                                        Else
                                                GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $hGui)
                                        EndIf
                        EndSelect
                Case $hGui
                        Select
                                Case $iMsg = $idLayButt
                                        Local $iTransColor, $iAlpha
                                        Local $iInfo = _WinAPI_GetLayeredWindowAttributes($hGui, $iTransColor, $iAlpha)
                                        MsgBox($MB_SYSTEMMODAL, 'Layered GUI', "Button on layered Window Clicked" & @CRLF & "Information about this window: " & @CRLF & _
                                                        "Transparent Color: " & $iTransColor & @CRLF & _
                                                        "Alpha Value: " & $iAlpha & @CRLF & _
                                                        "LWA_COLORKEY: " & (BitAND($iInfo, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _
                                                        "LWA_ALPHA: " & (BitAND($iInfo, $LWA_ALPHA) = $LWA_ALPHA))
                                Case $iMsg = $GUI_EVENT_CLOSE
                                        Exit MsgBox($MB_SYSTEMMODAL, '', "Close from Layered GUI")
                        EndSelect
        EndSwitch
WEnd
 楼主| 发表于 2018-3-10 21:34:19 | 显示全部楼层
回复 3# tubaba


    非常感谢指点
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 15:37 , Processed in 0.100205 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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