能够 做到 控件半透明 但是 窗口不透明吗?? 范例只有全部透明!!
能够 做到 控件半透明 但是 窗口不透明吗?? 范例只有全部透明!!#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
Local $gui = GUICreate("WinAPI UDF 函数演示", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
GUICtrlCreateLabel("这是一个透明分层 GUI 的文本", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "按住标签拖动分层窗口")
Local $layButt = GUICtrlCreateButton("测试", 10, 40, 40)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($gui, 0x010101)
GUISetState()
Local $guicontrol = GUICreate("ControlGUI", 300, 400, 100, 100)
Local $checkTrans = GUICtrlCreateCheckbox("透明色 0xABCDEF (选中) 或 0x010101", 10, 10)
Local $checkBorder = GUICtrlCreateCheckbox("弹出样式", 10, 30)
GUICtrlCreateLabel("分层 GUI 界面的透明度", 10, 50)
Local $slidTrans = GUICtrlCreateSlider(10, 70, 200, 30)
GUICtrlSetLimit($slidTrans, 255, 0)
GUICtrlSetData(-1, 255)
GUISetState()
While 1
Local $extMsg = GUIGetMsg(1)
Local $msg = $extMsg
Switch $extMsg
Case $guicontrol
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $checkTrans Or $msg = $slidTrans
; 更改跨窗口颜色和透明度的属性
If BitAND(GUICtrlRead($checkTrans), $GUI_CHECKED) = $GUI_CHECKED Then
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, GUICtrlRead($slidTrans))
Else
_WinAPI_SetLayeredWindowAttributes($gui, 0x010101, GUICtrlRead($slidTrans))
EndIf
Case $msg = $checkBorder
If BitAND(GUICtrlRead($checkBorder), $GUI_CHECKED) = $GUI_CHECKED Then
GUISetStyle($WS_POPUP, -1, $gui)
Else
GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $gui)
EndIf
EndSelect
Case $gui
Select
Case $msg = $layButt
Local $transcolor, $alpha
Local $info = _WinAPI_GetLayeredWindowAttributes($gui, $transcolor, $alpha)
MsgBox(0, '分层 GUI', "分层窗口按钮点击" & @CRLF & "此窗口信息: " & @CRLF & _
"透明颜色: " & $transcolor & @CRLF & _
"Alpha 值: " & $alpha & @CRLF & _
"LWA_COLORKEY: " & (BitAND($info, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _
"LWA_ALPHA: " & (BitAND($info, $LWA_ALPHA) = $LWA_ALPHA))
Case $msg = $GUI_EVENT_CLOSE
Exit MsgBox(0, '', "关闭分层界面")
EndSelect
EndSwitch
WEnd
哇 写个窗体代码那么长 进来学习下
页:
[1]