Jump to content

Recommended Posts

Posted

Hi Guys

I have this function from the help file, but was wondering how to toggle the marquee progress bar

Am I on the right track, as shown below?

Cheers

Func _UpdateProgbar($onoff)
    ;0 for off, 1 for on
    
    ; Embed a progress bar
    If @OSTYPE = "WIN32_WINDOWS"  Then
        $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
        $hProgress = GUICtrlGetHandle($progress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
    Else
        $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_MARQUEE) ; marquee works on Win XP and above
        $hProgress = GUICtrlGetHandle($progress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
        If $onoff <> 0 Then
            _SendMessage($hProgress, $PBM_SETMARQUEE, True, 200) ; marquee works on Win XP and above
        Else
            _SendMessage($hProgress, $PBM_SETMARQUEE, False, 200) ; marquee works on Win XP and above ;Not sure on this???????
        EndIf
    EndIf
    
EndFunc   ;==>_UpdateProgbar
Posted

Hi Guys

I have this function from the help file, but was wondering how to toggle the marquee progress bar

Am I on the right track, as shown below?

Cheers

Func _UpdateProgbar($onoff)
    ;0 for off, 1 for on
    
    ; Embed a progress bar
    If @OSTYPE = "WIN32_WINDOWS"  Then
        $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
        $hProgress = GUICtrlGetHandle($progress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
    Else
        $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_MARQUEE) ; marquee works on Win XP and above
        $hProgress = GUICtrlGetHandle($progress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
        If $onoff <> 0 Then
            _SendMessage($hProgress, $PBM_SETMARQUEE, True, 200) ; marquee works on Win XP and above
        Else
            _SendMessage($hProgress, $PBM_SETMARQUEE, False, 200) ; marquee works on Win XP and above ;Not sure on this???????
        EndIf
    EndIf
    
EndFunc   ;==>_UpdateProgbar
I think you have got it basically correct, but you don't want to recreate the progress bar every time you turn it on or off so I would split the function into 2. Maybe like this

#include <guiconstants.au3>
#include <constants.au3>
#include <GuiStatusBar.au3>


$g = GUICreate("test")
$l = GUICtrlCreateLabel("Running",20,40,120,21)
GUISetState()

$hp = _UpdateProgbar()
SBOnOff($hp,True)
Sleep(6000)
GUICtrlSetData($l,"Now stopped")
SBOnOff($hp,False)

Sleep(5000)


Func _UpdateProgbar($hSb=0)
;creates the progress bar
    Local $pbStyle = $PBS_MARQUEE,$hpb

    If @OSTYPE = "WIN32_WINDOWS"  Then $pbStyle = $PBS_SMOOTH
    
    $progress = GUICtrlCreateProgress(0, 0, 200,30, $pbStyle)

    $hpb = GUICtrlGetHandle($progress)
    
    if $hSb <> 0 then _GUICtrlStatusBar_EmbedControl($hSb, 2, $hpb)

    return $hpb
EndFunc

Func SBOnOff($bar, $onoff)
    If @OSTYPE = "WIN32_WINDOWS"  Then return;no marquee effect to stop

    _SendMessage($bar, $PBM_SETMARQUEE, $onoff, 200); marquee works on Win XP and above
EndFunc
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.
  • 2 weeks later...
Posted

Following on from this example, how could I delete or hide the embedded progress bar control after it has been switched off?

Cheers

Posted

Something like this

#include <guiconstants.au3>
#include <constants.au3>
#include <GuiStatusBar.au3>


$g = GUICreate("test")
$l = GUICtrlCreateLabel("Running",20,40,120,21)
GUISetState()

$hp = _UpdateProgbar()
For $i = 1 To 3
    SBOnOff($hp,True)
    GUICtrlSetState(-1, $GUI_SHOW)
    Sleep(3000)
    GUICtrlSetData($l,"Now stopped")
    SBOnOff($hp,False)
    GUICtrlSetState(-1, $GUI_HIDE)
    Sleep(3000)
Next

Func _UpdateProgbar($hSb=0)
;creates the progress bar
    Local $pbStyle = $PBS_MARQUEE,$hpb

    If @OSTYPE = "WIN32_WINDOWS"  Then $pbStyle = $PBS_SMOOTH
    
    $progress = GUICtrlCreateProgress(0, 0, 200,30, $pbStyle)

    $hpb = GUICtrlGetHandle($progress)
    
    if $hSb <> 0 then _GUICtrlStatusBar_EmbedControl($hSb, 2, $hpb)

    return $hpb
EndFunc

Func SBOnOff($bar, $onoff)
    If @OSTYPE = "WIN32_WINDOWS"  Then return;no marquee effect to stop

    _SendMessage($bar, $PBM_SETMARQUEE, $onoff, 200); marquee works on Win XP and above
EndFunc

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
  • Recently Browsing   0 members

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