Jump to content

Progress bar vertical and smooth


johngbauer
 Share

Recommended Posts

I am using the following code to try to get a vertical smoothed progress bar but it comes out segmented.

I have tried several variaions with no luck

CODE
9/11/07

; johngbauer

#include <GUIConstants.au3>

dim $p01val,$sv

GUICreate ("Options",400,400)

$p01 = GUICtrlCreateProgress (10,10,200,200, BitOR ($PBS_SMOOTH, $PBS_VERTICAL))

$okbutton = GUICtrlCreateButton("OK",210,210,50)

GUISetState (@SW_SHOW)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

MsgBox(0,"Closing","Closing",1)

exitloop

Case $msg = $okbutton

$p01val=$p01val+5

GUICtrlSetData($p01,$p01val)

MsgBox(0,"OK",$p01val,2)

EndSelect

Wend

Sleep(5000

Link to comment
Share on other sites

And you won't have any luck if you're running on WinXP with modern (default) themes. Smooth works only with Classic theme, as been noted many times in the past. That's just how Windows go, for whatever reason.

If smooth look is important to you, you can try some custom made progress bars, there are quite a few of those in examples forum.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Wow, good call. There is a way to force theme (and not necessarily for whole window, for a single control too), it's SetWindowTheme.

Works like this (based on GUICtrlCreateProgress example from helpfile):

#include <GUIConstants.au3>


GUICreate("My GUI Progressbar",220,100, 100,200)

$progressbar1 = GUICtrlCreateProgress (10,10,200,20,$PBS_SMOOTH)
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($progressbar2), "wstr", "", "wstr", "")
$button = GUICtrlCreateButton ("Start",75,70,70,20)

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

    $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
Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Wow, good call. There is a way to force theme (and not necessarily for whole window, for a single control too), it's SetWindowTheme.

Works like this (based on GUICtrlCreateProgress example from helpfile):

#include <GUIConstants.au3>
GUICreate("My GUI Progressbar",220,100, 100,200)

$progressbar1 = GUICtrlCreateProgress (10,10,200,20,$PBS_SMOOTH)
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($progressbar2), "wstr", "", "wstr", "")
$button = GUICtrlCreateButton ("Start",75,70,70,20)

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

    $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

:)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Eh?

Sorry if I confused you, I was just trying to say "That's good, I like that, thanks" without spending time writing. Didn't work did it.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...