透明GUI窗口,如何让边框不透明?【已解决】
本帖最后由 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 或者说,有没办法创建这样的窗体:
即红色部分为GUI,其他部分都不是GUI
鼠标可以直接点击非GUI部分
例如,图中,我可以鼠标直接点击软件(D:)就可以打开D盘 回复 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
Switch $aExtMsg
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
回复 3# tubaba
非常感谢指点{:face (254):}
页:
[1]