Jump to content

Recommended Posts

  • Moderators
Posted (edited)

There was a request for a Marquee Style Progress Control, so I did some research and came up with these.

Requires: AutoIt Beta and Windows XP or later

;===============================================================================
;
; Function Name:    _GUICtrlProgressMarqueeCreate()
; Description:      Creates a marquee sytle progress control
; Parameter(s):     $i_Left     - The left side of the control
;                   $i_Top      - The top of the control
;                   $i_Width    - Optional: The width of the control
;                   $i_Height   - Optional: The height of the control
; Requirement(s):   AutoIt3 Beta and Windows XP or later
; Return Value(s):  On Success - Returns the identifier (controlID) of the new control
;                  On Failure - Returns 0  and sets @ERROR = 1
; Author(s):        Bob Anthony
;
;===============================================================================
;
Func _GUICtrlProgressMarqueeCreate($i_Left, $i_Top, $i_Width = Default, $i_Height = Default)
    
    Local Const $PBS_MARQUEE = 0x08
    
    Local $v_Style = $PBS_MARQUEE
    
    Local $h_Progress = GUICtrlCreateProgress($i_Left, $i_Top, $i_Width, $i_Height, $v_Style)
    If $h_Progress = 0 Then
        SetError(1)
        Return 0
    Else
        SetError(0)
        Return $h_Progress
    EndIf
    
EndFunc;==>_GUICtrlProgressMarqueeCreate

;===============================================================================
;
; Function Name:    _GUICtrlProgressSetMarquee()
; Description:      Sets marquee sytle for a progress control
; Parameter(s):     $h_Progress - The control identifier (controlID)
;                   $f_Mode     - Optional: Indicates whether to turn the marquee mode on or off
;                                   0 = turn marquee mode off
;                                   1 = (Default) turn marquee mode on
;                   $i_Time     - Optional: Time in milliseconds between marquee animation updates
;                                   Default is 100 milliseconds
; Requirement(s):   AutoIt3 Beta and Windows XP or later
; Return Value(s):  On Success - Returns whether marquee mode is set
;                  On Failure - Returns 0  and sets @ERROR = 1
; Author(s):        Bob Anthony
;
;===============================================================================
;
Func _GUICtrlProgressSetMarquee($h_Progress, $f_Mode = 1, $i_Time = 100)
    
    Local Const $WM_USER = 0x0400
    Local Const $PBM_SETMARQUEE = ($WM_USER + 10)
    
    Local $var = GUICtrlSendMsg($h_Progress, $PBM_SETMARQUEE, $f_Mode, Number($i_Time))
    If $var = 0 Then
        SetError(1)
        Return 0
    Else
        SetError(0)
        Return $var
    EndIf
    
EndFunc;==>_GUICtrlProgressSetMarqueeoÝ÷ Øw«z+ìZ^¡ûazëjëh×6#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$GUI = GUICreate("Marquee Progress Bar", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CLOSE")

$GUI_Progress = _GUICtrlProgressMarqueeCreate(50, 25, 100, 20)
$GUI_Button_Start = GUICtrlCreateButton("Start", 40, 50)
GUICtrlSetOnEvent(-1, "Progress_Start")
$GUI_Combo = GUICtrlCreateCombo("", 78, 52, 50)
GUICtrlSetData(-1,"1|10|50|100|300|500") 
GUICtrlSetOnEvent(-1, "Progress_Time")
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 135, 50)
GUICtrlSetOnEvent(-1, "Progress_Stop")
GUISetState()

While 1
    Sleep(100)
WEnd

Func Progress_Start()
    _GUICtrlProgressSetMarquee($GUI_Progress)
EndFunc;==>Progress_Start

Func Progress_Stop()
    _GUICtrlProgressSetMarquee($GUI_Progress, 0)
EndFunc;==>Progress_Stop

Func Progress_Time()
    $iTime = GUICtrlRead($GUI_Combo)
    _GUICtrlProgressSetMarquee($GUI_Progress, 1, $iTime)
EndFunc;==>Progress_Time

Func GUI_CLOSE()
    Exit
EndFunc;==>GUI_CLOSE

Edit: Add Image

Edit: Updated Example

Edit: Added Syntax Highlighting

Edited by big_daddy
Posted

Before I looked at the sample, I didnt know what the marquee progress control was. Nice little UDF you have here. I had to include the UDF to get it to work, of course.

Nice job.

Posted

Thanks, Very nice. :)

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

  • 2 weeks later...
  • 4 months later...
  • Moderators
Posted

How would I go about setting the data of the Progress Bar to ""? It seems no matter what I do, it ends up showing 4 bars on creation.

Sorry, but I was unable to find a solution for you on this.
Posted

Sorry, but I was unable to find a solution for you on this.

Well I appreciate you looking, please let me know if you find one in the future. I'm probably going to use marquee anyway, it's just odd looking when the control has not yet been used, but has data... heh

Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki
Posted (edited)

don't feel like searching but i think gafrost made one of these a long while ago

but still, neat

Edited by layer
FootbaG

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...