Sign in to follow this  
Followers 0
UnReAl

How can i set the color of a progress bar?

5 posts in this topic

Hi all

I wanted to create a red progressbar using the $PBS_SMOOTH style. If i read the help file i found this: (from autoitv3.chm)

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic and Progress controls can currently be colored.

Checkbox, Radio or cannot be painted if the "Windows XP style" is used.

The $PBS_SMOOTH style and painting the progressbar don`t works with the Win XP style,

but i don`t want to change the style of my computer everytime i run this programm!

Can i do something so that only the gui is using win98 style?


Share this post


Link to post
Share on other sites



Like this

#include <GUIConstants.au3>
Dim $XS_n
GUICreate("My GUI Progressbar",220,100, 100,200)
XPStyle(1)   
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
XPStyle(0)   
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"Stop")
    For $i = $s To 100
    If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
    $m = GUIGetMsg ()
   
    If $m = -3 Then ExitLoop
   
    If $m = $button Then
      GUICtrlSetData ($button,"Next")
      $s = $i;save the current bar-position to $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,$i)
      GUICtrlSetData ($progressbar2,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;        $s=0
        GUICtrlSetData ($button,"Start")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE


Func XPStyle($OnOff = 1)   
    If $OnOff And StringInStr(@OSTYPE, "WIN32_NT") Then
        $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return 1
    ElseIf StringInStr(@OSTYPE, "WIN32_NT") And IsArray($XS_n) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
        $XS_n = ""
        Return 1
    EndIf
    Return 0
EndFunc   ;==>XPStyle

there are more helpful "scriplets" in Autoit Wrappers located here....

http://www.autoitscript.com/forum/index.ph...st&p=133769

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thx for your fast help :)


Share this post


Link to post
Share on other sites

Thx for your fast help :)

Welcome!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0