StatusBar上的字体颜色能调吗?
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)_GUICtrlStatusBar_SetMinHeight($StatusBar1, 49)
GUICtrlSetFont(-1, 18, 800, 0, "楷体_GB2312")
GUICtrlSetColor(-1, 0x0000FF)控件本身没有这个选项,这个是我从input那复制的,但是不好使,有经验的说下 假的!
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 400, 300)
$Graphic1 = GUICtrlCreateGraphic(0, 270, 400, 5)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 5)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 400, 5)
$Label1 = GUICtrlCreateLabel("嘿嘿!这个算吗?", 10, 280, 150, 17)
GUICtrlSetColor(-1, 0xFF0000)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
EndSwitch
WEnd 本帖最后由 netegg 于 2011-2-3 14:53 编辑
原文地址#include <GUIConstantsEX.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
Opt('MustDeclareVars', 1)
Global $hFont
Global $aParts =
Global $aPartsText = ["RED on Transparent", "BLUE on Transparent"]
Global $hGUI = GUICreate("statusbar custom font and colour demo", 400, 300)
GUISetBkColor(0xE0FFFF)
Global $hStatus = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
Global $tPart0 = _GUICtrlStatusBar_SetColor($hStatus, $aPartsText, 0, 0xFF0000)
Global $tPart1 = _GUICtrlStatusBar_SetColor($hStatus, $aPartsText, 1, 0x0C0DC0)
_GUICtrlStatusBar_SetText($hStatus, "Not ownerdrawn", 2)
_GUICtrlStatusBar_SetFont($hStatus, 16, 800, 0, "Comic Sans MS")
GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM")
GUISetState()
$tPart0 = _GUICtrlStatusBar_SetColor($hStatus, $aPartsText, 0, 0xFF0000)
$tPart1 = _GUICtrlStatusBar_SetColor($hStatus, $aPartsText, 1, 0x0C0DC0)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_WinAPI_DeleteObject($hFont)
Func _GUICtrlStatusBar_SetFont($hWnd, $iHeight = 15, $iWeight = 400, $iFontAtrributes = 0, $sFontName = "Arial")
$hFont = _WinAPI_CreateFont($iHeight, 0, 0, 0, $iWeight, BitAND($iFontAtrributes, 2), BitAND($iFontAtrributes, 4), _
BitAND($iFontAtrributes, 8), $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, _
$DEFAULT_QUALITY, 0, $sFontName)
_SendMessage($hWnd, $WM_SetFONT, $hFont, 1)
EndFunc ;==>_GUICtrlStatusBar_SetFont
Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam, $lParam
Local $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;" & _
"uint itmAction;uint itmState;hwnd hItm;hwnd hDC;int itmRect;dword itmData", $lParam)
Local $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm"); retrieve statusbar handle
Switch _WinAPI_GetClassName($hItm)
Case "msctls_statusbar32"
Local $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC")
Local $iID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID")
Local $pParam = DllStructGetData($tagDRAWITEMSTRUCT, "itmData")
Local $tParam = DllStructCreate("wchar;dword;dword;dword", $pParam)
Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom")
DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 1)
DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) + 1)
DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3))
DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4))
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
_WinAPI_SetTextColor($hDC, DllStructGetData($tParam, 2))
If Not DllStructGetData($tParam, 4) Then
Local $iBkColor = DllStructGetData($tParam, 3), $hStatusDC, $hBrushBk
$hStatusDC = _WinAPI_GetDC($hItm)
$hBrushBk = _WinAPI_CreateSolidBrush($iBkColor)
_WinAPI_FillRect($hStatusDC, DllStructGetPtr($tRECT), $hBrushBk)
_WinAPI_DeleteObject($hBrushBk)
_WinAPI_ReleaseDC($hItm, $hStatusDC)
EndIf
_WinAPI_DrawText($hDC, DllStructGetData($tParam, 1), $tRECT, $DT_LEFT)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_DRAWITEM
Func _GUICtrlStatusBar_SetColor($hWnd, $sText = "", $iPart = 0, $iColor = 0, $iBkColor = -1)
Local $ret, $tStruct, $pStruct, $iBuffer
$tStruct = DllStructCreate("wchar Text;dword Color;dword BkColor;dword Trans")
Switch $iBkColor
Case -1
DllStructSetData($tStruct, "Trans", 1)
Case Else
$iBkColor = BitAND(BitShift(String(Binary($iBkColor)), 8), 0xFFFFFF)
DllStructSetData($tStruct, "Trans", 0)
DllStructSetData($tStruct, "BkColor", $iBkColor)
EndSwitch
$iColor = BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
DllStructSetData($tStruct, "Text", $sText)
DllStructSetData($tStruct, "Color", $iColor)
$pStruct = DllStructGetPtr($tStruct)
If _GUICtrlStatusBar_IsSimple($hWnd) Then $iPart = $SB_SIMPLEID
If _WinAPI_InProcess($hWnd, $__ghSBLastWnd) Then
$ret = _SendMessage($hWnd, $SB_SetTEXTW, BitOR($iPart, $SBT_OWNERDRAW), $pStruct, 0, "wparam", "ptr")
Return $tStruct
EndIf
Return 0
EndFunc ;==>_GUICtrlStatusBar_SetColor
{:1_552:}万分感激!
水木子,鼬哥哥,写写你哦
同样感激三楼
我发了不少很傻的问题,都得到了回答 我感觉我的帖子对新人都有很大的帮助,嘿嘿 这个好像很不错哦..
页:
[1]