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

[GUI管理] [已解决]再请教一个问题?输入文字的背景可不可以设为透明?

  [复制链接]
发表于 2011-1-11 11:09:18 | 显示全部楼层 |阅读模式
本帖最后由 lchuangyu 于 2011-1-16 09:36 编辑

新建了GUI界面
GUICtrlCreateLabel样式背景怎么设为透明?

本帖子中包含更多资源

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

×
发表于 2011-1-11 13:20:21 | 显示全部楼层
GUICtrlCreateLabel 帮助里有写

要设置背景为透明,请使用 GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT).
发表于 2011-1-11 13:21:54 | 显示全部楼层
论坛里有这样的例子的。 我发一个我综合了几个人的代码你看看。
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

; ●○

$pi = 3.14159265358979
Local $iCount = 0
Local $iColor = 1
Local $PointNum=1
;颜色控制变量
Local $color
        
$Form1 = GUICreate("圆", 300, 300,300,200,$WS_POPUP,bitor($WS_EX_LAYERED,$WS_EX_TOOLWINDOW))
GUISetBkColor(0xFFFBF0)
_API_SetLayeredWindowAttributes($Form1, 0xFFFBF0,255,False)
$Label1 = GUICtrlCreateLabel("●", 150, 100, 20, 20)
GUICtrlSetColor($Label1, 0xff0000)

$x = 50 * sin( 20 * $pi / 180)

for $i = 1 to 24 Step 1
        $x = 50 * cos(15 * $i * $pi / 180)
        $y = 50 * sin(15 * $i * $pi / 180)
        $Label = GUICtrlCreateLabel("○", 150 + $x, 100 + $y, 10, 10)
        GUICtrlSetColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Next
$strInfo = GUICtrlCreateLabel("正在扫描系统信息,请稍后......", 70, 200)

AdlibRegister('_TimerProc',100)
;2.5秒变换一次颜色
AdlibRegister('_colorchange',2500)
GUISetState(@SW_SHOW)
;随即数生成颜色值
Func _ColorChange()
        $color=Random(0x000000,0xffffff,1)
EndFunc
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency, $isColorRef)

Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
Select
Case @error
Return SetError(@error, 0, 0)
Case $Ret[0] = 0
Return SetError(4, 0, 0)
Case Else
Return 1
EndSelect
EndFunc
Func _TimerProc()
        $iCount = $iCount + 1
        $x = 50 * cos(15 * $iCount * $pi / 180)
        $y = 50 * sin(15 * $iCount * $pi / 180)
        $Label = GUICtrlCreateLabel("★", 150 + $x, 100 + $y, 12, 12)
        if 0 = Mod($iColor,2) Then
                GUICtrlSetColor(-1, $color)
        Else
                $color=BitOR($color,0x0f000F)
                GUICtrlSetColor(-1,  $color)
        EndIf
        Sleep(100)
        
        If Mod($iCount,24) = 0 Then
                $iColor = $iColor + 1
        EndIf
        ;显示的文字信息也动作
        Select 
                Case $PointNum=1
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后.")
                Case $PointNum=2
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后..")
                Case $PointNum=3
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后...")
                Case $PointNum=4
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后....")
                Case $PointNum=5
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后.....")
                Case $PointNum=6
                        GUICtrlSetData($strInfo,"正在扫描系统信息,请稍后......")
        EndSelect
        ;文字后的点数量加一
        $PointNum=$PointNum+1
        ;如果文字后的点数量大于6,则将数量值置一
        If $PointNum>6 Then $PointNum=1
        ;将显示过的实心圆再设置成空心的
        ;GUICtrlDelete($Label)
EndFunc
        

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        AdlibUnRegister('_TimerProc')
                        Exit

        EndSwitch
WEnd

GUISetState(@SW_SHOW)

发表于 2011-1-11 13:24:21 | 显示全部楼层
你试试其中的_API_SetLayeredWindowAttributes函数  如果HWND参数设置为控件, 有没有效果。
 楼主| 发表于 2011-1-11 19:33:21 | 显示全部楼层
回复 2# sxd


    谢谢你了,把你给我的放进去了成功!!!
 楼主| 发表于 2011-1-11 19:36:09 | 显示全部楼层
回复 4# lanfengc

                    我拿这个代码放进去了出现错误

本帖子中包含更多资源

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

×
发表于 2011-1-11 20:30:46 | 显示全部楼层
回复  sxd


    谢谢你了,把你给我的放进去了成功!!!
lchuangyu 发表于 2011-1-11 19:33


大哥我只是想和你说 以后看帮助看仔细点 其实很多东西在帮助里都有的
 楼主| 发表于 2011-1-12 10:13:38 | 显示全部楼层
回复 7# sxd


    好的,谢谢,我以后会注意看的
发表于 2011-6-5 15:11:21 | 显示全部楼层
收藏了。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 01:26 , Processed in 0.080513 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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