ipmitool 发表于 2017-1-18 08:24:36

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

本帖最后由 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

gto250 发表于 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
                $aProgress =$width
      
                $aProgress = GUICtrlCreateLabel("", $left,$top,0,$height, $SS_CENTER)
                GUICtrlSetBkColor(-1, 0x00FF00)
                $aProgress = 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
ControlMove($Form,"",$Progress,Default,Default,$v)
GUICtrlSetData($Progress,$data*10&"%")
If $data>5 Then
GUICtrlSetBkColor($Progress,0xff0000)       
EndIf
EndFunc       

页: [1]
查看完整版本: [已解决]請問label status bar如何讓值超過5時bar就顯示紅色