SB_SetProgress
___________________________________________________________________
Creates and controls a progressbar placed atop the last known AHK Gui's Statusbar control.
SB_SetProgress([param1 [, segment [, options]]])
Parameters wrote: |
Param1
Needs to be a number in the given range of the progressbar, its bar's position is changed to that value.
The default range can be changed with the method described below. By default it is from 0 to 100.
Segment
Specify the segment you wish to attach the Progressbar to. If you want
only to change it's appearance with the options, and no segments are
defined, use 1 which is also the default value.
Options
A string of zero or more options from the list further below. |
___________________________________________________________________
Usable Options
+/-Smooth: Displays a length of
segments rather than a smooth continuous bar. Specifying -Smooth is
also one of the requirements to show a themed progress bar on Windows
XP or later. The other requirement is that the bar not have any custom
colors; that is, that the C and Background options be omitted. Windows
95 and NT4 require Internet Explorer 3.0 or later to support this
option.
+/-Range: Sets the range to be
something other than 0 to 100. After the word Range, specify the
minimum, a dash, and maximum. For example, Range0-1000 would allow a
numbers between 0 and 1000; Range-50-50 would allow numbers between -50
and 50; and Range-10--5 would allow numbers between -10 and -5. On
Windows 95 and NT4, negative ranges and ranges beyond 65535 will not
behave correctly unless Internet Explorer 3.0 or later is installed.
Using -Range (minus range) will reset the range to standard defaults.
Cn: Changes the bar's color. Specify for n
one of the 16 primary HTML color names or a 6-digit RGB color value.
Examples: cRed, cFFFF33, cDefault. If the C option is never used (or
cDefault is specified), the system's default bar color will be used.
BackgroundN: Changes the bar's background color. Specify for n
one of the 16 primary HTML color names or a 6-digit RGB color value.
Examples: BackgroundGreen, BackgroundFFFF33, BackgroundDefault. If the
Background option is never used (or BackgroundDefault is specified),
the background color will be that of the window or tab control behind
it.
Enable: Enables a control if it was previously disabled. On by default.
Disable: Disables or "grays out" a control.
Show: Shows a control if it was previously hidden.
Hide: Hides the progressbar control.
___________________________________________________________________
ErrorLevel
In case an error happens, The ErrorLevel will contain informations
about what went wrong. All Descriptions start with the word "FAIL:"
written in caps. Possible contents and a brief explanation:
No StatusBar Control
Obvious.
Wrong Segment Parameter
Will be set when Segment parameter is smaller or equal zero.
Wrong Segment Count
Will be set when higher Segment number is given than actual segements exist. Exception:
When operating with just a standard statusbarcontrol and no segments at
all, a given Segment parameter can be used to have more than just one
Progressbar of which only the latest according to its z-Order will be
displayed.
Segmentdimensions
The function was unable to determine given Segment's dimensions (x/y of upper left corner and x/y of lower right corner)
On success the ErrorLevel will contain 1
___________________________________________________________________
Returnvalue
When an Error of the pervious described occurs, the returnvalue
will be set to -1. On success to the progressbar's WindowHandle (hWnd).
___________________________________________________________________
Performance
Allthough it works, it is better not to supply options directly at a loop which will permanently update the statusbar.
This may result in flickering of the progressbar due to parsing all
comments on each run. Better is to use Seperate commands, and have just
passed Param1 and Segemt to update the progressbar. See the example
below how to use this properly.
___________________________________________________________________
Remarks
Currently the so called marqueestyle (that is no given size, but a contantly moving part of the bar) is not functional.
The -Smooth/+Smooth parameter will only be evaluated upon
Progressbar creation and cannot be changed from within the function
lateron.
Using the PBM_DELTAPOS message to increment the Bar by a given step and not by an absolute number is not implemented yet.
So something comparable to
Code: | GuiControl,, MyProgress, +20 ; Increase the current position by 20. |
won't work at the moment.
To get the current's Progressbar value (if ever needed) a SendMessage must be used like this:
Code: | hwnd := SB_SetProgress(50,3,"BackgroundYellow cBlue") ; This is the way to obtain the handle to the control SendMessage, PBM_GETPOS:=0x408, wParam:=0, lParam:=0,,ahk_id %hWnd% ; wParam, and lParam needs to be zero in this case MsgBox %ErrorLevel% ; The ErrorLevel contains the current position |
___________________________________________________________________
Related
StatusBar, Progress, Styles
___________________________________________________________________
Resources
Progress Bar Control Reference > Messages
http://msdn.microsoft.com/en-us/library/cc656531(VS.85).aspx
[ahksushi] Statusbar with Progressbar and animated Icon
http://www.autohotkey.com/forum/viewtopic.php?t=37674
[Solved] How to send an array with SendMessage
http://www.autohotkey.com/forum/topic6017.html
[tutorial] Creating windows without GUI commands
http://www.autohotkey.com/forum/viewtopic.php?t=22904
___________________________________________________________________
Examples
Code: | SB_SetProgress(10) ; will create a progress onto entire statusbar showing 10% bar |
A little working example:
Code: | Gui,add,text,w280 center,Some text for the gui! Gui,add,statusbar Gui,show,w300,Statusbar with Progress
SB_SetParts(20,200,100) ; Make 3 different parts SB_SetText("demotext",2) ; Set a text segment 2 SB_SetIcon(A_AhkPath,1,1) ; Set an Icon to 1st segment ; create a 50% progressbar with yellow background and blue bar hwnd := SB_SetProgress(50,3,"BackgroundYellow cBlue") return |
This example shows advanced features of the SB_SetProgress function
Code (Expand): | ; ahk-Sushi: Anime Icon + Progressbar in Statusbar ; (w) Nov 2008 by DerRaphael(at)oleco.net ; modified for SB_SetProgress demonstration
gui,add,text,w180 center y10,Demo anime Icon`n+ Progressbar in StatusbarControl gui,add,button,x+10 yp-3 w90 gRestart vBtn1 default, Restart! Gui,add,statusbar, hwndhwndBar gui,show,w300,[ahksushi] Statusbar Demo
SB_SetParts(20,200,100) SB_SetText("demotext",2) hIS := SB_SetIcon(A_AhkPath,1,1) hwnd := SB_SetProgress(50,3,"BackgroundGreen cLime") Gosub, Prep_Animation
Restart: SB_SetProgress(0,3,"show") GuiControl,Disable,Btn1 Gui,+LastFound ControlFocus pp := 0 SetTimer,ProgressAnimation,50 return
ProgressAnimation: SB_SetProgress(++pp,3) R := mod(pp,8)//2+1 SendMessage, 0x40F, 0, hI%R%,, ahk_id %hwndBar% ; SB_SETICON := (WM_USER:=0x400) + 15 - icon animation! if (pp=100) { SendMessage, 0x40F, 0, hIS,, ahk_id %hwndBar% ; StandardIcon hIS SB_SetText("`tEat mo' sushi!",2,0) ; update Text SetTimer,ProgressAnimation,Off ; Timer OFF GuiControl,Enable,Btn1
SB_SetText("`tDone!",3,0)
; update Text
SB_SetProgress(0,3,"hide")
; hide the progress } else ; update Text SB_SetText("`tLala lala la: " pp " %",2,0) Return
Prep_Animation: ; Prepare Animation - Load 4 Icons and make their handle available hInst := DllCall("GetModuleHandle", "str", "shell32.dll") Loop,4 hI%A_index% := DllCall("LoadImage", "Uint", hInst, "Uint", 3+A_index, "Uint", 1 , "int", 16, "int", 16, "Uint", 0x8000) Return
GuiEscape: GuiClose: exitapp |
|
|
|
|