qsy666888 发表于 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 =

    ; 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

lpxx 发表于 2014-6-13 08:00:01

是这种效果么,我有收藏
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $hGUI, $hStatus
Global $aParts =

$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;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

qsy666888 发表于 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画一个{:face (125):}

lpxx 发表于 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, $size)
$hStatus = _GUICtrlStatusBar_Create($gui)
Local $aParts =
_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

lpxx 发表于 2014-6-13 17:34:18

回复lpxx

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

你这是Demo 1、Demo 2、Demo 3 控件的背景色,我想的是 ...
qsy666888 发表于 2014-6-13 08:52 http://www.autoitx.com/images/common/back.gif

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

Local $I
Local $aColors =
Local $aParts =
_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

qsy666888 发表于 2014-6-13 18:42:07

回复 6# lpxx

谢谢,先研究研究

ak47gglllk 发表于 2014-6-14 08:51:54

路过,看看大神写的东西,学习学习
页: [1]
查看完整版本: 状态栏颜色如何设置?请教大侠们,