找回密码
 加入
搜索
查看: 1409|回复: 1

[AU3基础] [已解决]請問label status bar如何讓值超過5時bar就顯示紅色

[复制链接]
发表于 2017-1-18 08:24:36 | 显示全部楼层 |阅读模式
本帖最后由 ipmitool 于 2017-2-13 09:46 编辑
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>


#Region ### START Koda GUI section ### Form=
GUICreate("GUI", 294, 69, 192, 124)
$idProgressBar = GUICtrlCreateProgress(8, 24, 278, 24, $PBS_SMOOTH)
$idLabel = GUICtrlCreateLabel("", 8, 24, 276, 22, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$i = 7
    GUICtrlSetData($idProgressBar, CalcPercent($i, 10))
    If $i > 5 Then
                GUICtrlSetColor($idLabel,0xffffff)
            GUICtrlSetBkColor(-1, $COLOR_RED)
                GUICtrlSetData($idLabel, $i)
        EndIf



    Sleep(1000)


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

    EndSwitch
WEnd

Func CalcPercent($iPartDone, $iTotal, $iRoundToDecimalPlace = 1)
    Return Round(($iPartDone / $iTotal) * 100, $iRoundToDecimalPlace)
EndFunc
发表于 2017-2-10 21:31:23 | 显示全部楼层
将就用一下吧
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>



$gui=GUICreate("GUI", 294, 88, 192, 124)
$idProgressBar1 =_Progress_Create(8, 24, 278, 24)
$idProgressBar2 =_Progress_Create(8, 49, 278, 24)





GUISetState(@SW_SHOW)

_progress_SetDate($gui,$idProgressBar1,5)
for $i=1 To 10

_progress_SetDate($gui,$idProgressBar2,$i)
sleep(500)
Next
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd



Func _Progress_Create($left,$top,$width,$height)
         Local $aProgress[3]
                $aProgress[0] =$width
        
                $aProgress[2] = GUICtrlCreateLabel("", $left,$top,0,$height, $SS_CENTER)
                GUICtrlSetBkColor(-1, 0x00FF00)
                $aProgress[1] = GUICtrlCreateLabel("", $left,$top,$width,$height, BitOR($SS_CENTER,$SS_CENTERIMAGE))
                GUICtrlSetColor(-1,0x000000)
                GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        Return $aProgress        
EndFunc        

Func _progress_SetDate($Form,$progress,$data)
$v=$data/10*$progress[0]
ControlMove($Form,"",$Progress[2],Default,Default,$v)
GUICtrlSetData($Progress[1],$data*10&"%")
If $data>5 Then
GUICtrlSetBkColor($Progress[2],0xff0000)        
EndIf
EndFunc        

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 15:18 , Processed in 0.075294 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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