找回密码
 加入
搜索
查看: 6463|回复: 7

[AU3基础] 状态栏颜色如何设置?请教大侠们,

  [复制链接]
发表于 2014-6-12 22:39:19 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WinAPI.au3>
#include <Constants.au3>

$Debug_SB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()

    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Set BkColor", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    GUISetState()

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set background color
    _GUICtrlStatusBar_SetBkColor($hStatus, 0xFFFF00)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main
发表于 2014-6-13 08:00:01 | 显示全部楼层
是这种效果么,我有收藏
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $hGUI, $hStatus
Global $aParts[3] = [75, 150, -1]

$hGUI = GUICreate("Demo", 400, 300)
GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM")
$hStatus = _GUICtrlStatusBar_Create($hGUI)
GUISetState()

;~ _GUICtrlStatusBar_SetBkColor($hStatus, 0x5555DD)

_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "Demo 1", 0, $SBT_OWNERDRAW)
_GUICtrlStatusBar_SetText($hStatus, "Demo 2", 1, $SBT_OWNERDRAW)
_GUICtrlStatusBar_SetText($hStatus, "Demo 3", 2, $SBT_OWNERDRAW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()

Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam)
    Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID")    ;part number
    Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC")
    Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem"))
    Local $iTop = DllStructGetData($tRect, "top")
    Local $iLeft = DllStructGetData($tRect, "left")
    Local $hBrush

    Switch $itemID
        Case 0
            $hBrush = _WinAPI_CreateSolidBrush(0x555500)
            _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
            _WinAPI_SetBkMode($hDC, $TRANSPARENT)
            DllStructSetData($tRect, "top", $iTop + 1)
            DllStructSetData($tRect, "left", $iLeft + 1)
            _WinAPI_SetTextColor($hDC, 0x00FFFF)
            _WinAPI_DrawText($hDC, "Demo 1", $tRect, $DT_LEFT)
            _WinAPI_DeleteObject($hBrush)
        Case 1
            $hBrush = _WinAPI_CreateSolidBrush(0x00FF00)
            _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
            _WinAPI_SetBkMode($hDC, $TRANSPARENT)
            DllStructSetData($tRect, "top", $iTop + 1)
            DllStructSetData($tRect, "left", $iLeft + 1)
            _WinAPI_DrawText($hDC, "Demo 2", $tRect, $DT_LEFT)
            _WinAPI_DeleteObject($hBrush)
        Case 2
            $hBrush = _WinAPI_CreateSolidBrush(0xABCDEF)
            _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
            _WinAPI_SetBkMode($hDC, $TRANSPARENT)
            DllStructSetData($tRect, "top", $iTop + 1)
            DllStructSetData($tRect, "left", $iLeft + 1)
            _WinAPI_DrawText($hDC, "Demo 3", $tRect, $DT_LEFT)
            _WinAPI_DeleteObject($hBrush)
        EndSwitch

    $tDRAWITEMSTRUCT = 0
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_DRAWITEM

本帖子中包含更多资源

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

×
 楼主| 发表于 2014-6-13 08:52:15 | 显示全部楼层
本帖最后由 qsy666888 于 2014-6-13 09:05 编辑

回复 2# lpxx

嗯,要是中间的分隔去掉就更好了

你这是Demo 1、Demo 2、Demo 3 控件的背景色,我想的是状态栏控件 $hStatus 背景色,跟这个有点相似,感觉
发表于 2014-6-13 10:38:00 | 显示全部楼层
自己用PS画一个
发表于 2014-6-13 17:26:13 | 显示全部楼层
你的意思是不是这样,都有收藏的,测试环境,XP+3.3.6.1,其他环境没测试。
#include <Color.au3>
#include <GuiStatusBar.au3>

Global $GUI_GR_LINE = 2
Global $GUI_GR_MOVE = 6
Global $GUI_GR_COLOR = 8

$color1 = 0x000000
$color2 = 0x00f0ff
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)

$gui = GUICreate("Demo")
$size = WinGetClientSize($gui)
_GUICtrlCreateGradient($color1, $color2, 0, 0, $size[0], $size[1])
$hStatus = _GUICtrlStatusBar_Create($gui)
Local $aParts[3] = [175, 250, -1]
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "颜色值: " & $color2, 0,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetText($hStatus, "autoitx", 1,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetText($hStatus, "", 2,  $SBT_NOBORDERS)
_GUICtrlStatusBar_SetBkColor($hStatus, 0xf2e300)
GUISetState()
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend


Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)

    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight

    GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nHeight - $nY
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
    Next
EndFunc

本帖子中包含更多资源

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

×
发表于 2014-6-13 17:34:18 | 显示全部楼层
回复  lpxx

嗯,要是中间的分隔去掉就更好了

你这是Demo 1、Demo 2、Demo 3 控件的背景色,我想的是 ...
qsy666888 发表于 2014-6-13 08:52


再给你个例子参考下
#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>

Local $I
Local $aColors[4] = [0xFFFFFF, 0xFFF0FF, 0x494E49,0xCDCDCD]
Local $aParts[3] = [175, 250, -1]
_SetSameBackColor() 

For $I = 0 To 3
    _SetSameBackColor($aColors[$I]) 
Next

Func _SetSameBackColor($iColor = 0x50CA1B)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)
    Local $hGUI = GUICreate("状态栏的颜色")
    GUISetBkColor($iColor, $hGUI)
    Local $hStatus = _GUICtrlStatusBar_Create($hGUI)
    GUISetState()
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "颜色值 : " & $iColor)
    _GUICtrlStatusBar_SetText($hStatus, "Au3中文论坛", 1)
    _GUICtrlStatusBar_SetBkColor($hStatus, $iColor)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_SetSameBackColor

 

本帖子中包含更多资源

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

×
 楼主| 发表于 2014-6-13 18:42:07 | 显示全部楼层
回复 6# lpxx

谢谢,先研究研究
发表于 2014-6-14 08:51:54 | 显示全部楼层
路过,看看大神写的东西,学习学习
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-17 05:22 , Processed in 0.161775 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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