Ich habe eine UDF für Progressbars mit GDIplus geschrieben:
Die Basis war How about a progressbar like this? aus dem englischen Forum.
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.12.0
Author: Prog@ndy
after Script from nobbe ( 2008 in http://www.autoitscript.com/forum/index.ph…ndpost&p=485031 )
Script Function: A UDF for colored Progressbars with GDIPlus
Remarks: Theres an example from Line 22 to line 112 ( between the first #Region - #Endregion Tags
#ce ----------------------------------------------------------------------------
;===============================================================================
;
; Function Name: _ProgressCreate
; Description:: Creates a GDIplus Progressbar
; Parameter(s): $x : left
; $y : top
; $w : width
; $h : height
; $Col : [Optional] Top color of the foreground gradient
; $GradCol : [Optional] Bottom color of the foreground gradient
; $BG : [Optional] Top color of the background gradient
; $GradBG : [Optional] Bottom color of the background gradient
; Requirement(s): GDIplus
; Return Value(s): Success: ID of Progressbar, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressDelete
; Description:: Deletes a GDI+ Progressbar
; Parameter(s): $ID : ID of Progressbar
; Requirement(s): GDIplus
; Return Value(s): Sucess: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSetColors(
; Description:: Sets gradients as foreground and background
; Parameter(s): $ID : ID of Progressbar
; $Col : Top color of the foreground gradient
; $GradCol : Bottom color of the foreground gradient
; $BG : Top color of the background gradient
; $GradBG : Bottom color of the background gradient
; If $Col or $GradCol is -1, the foreground gradient isn't changed
; If $BG or $GradBG is -1, the background gradient isn't changed
; Requirement(s): Winapi.au3, GDIplus
; Return Value(s): Success: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSetImages(
; Description:: Sets images as foreground and background by Path
; Parameter(s): $ID : ID of Progressbar
; $ForeBmp : Path to image , empty String "" To leave the old
; The foreground image
; $BackBmp : [Optional] Path to image , empty String "" To leave the old
; The background image
; Requirement(s): Winapi.au3, GDIplus
; Return Value(s): Success: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSetHBitmaps(
; Description:: Sets previously loaded GDIplus Images / bitmaps as foreground and background
; Parameter(s): $ID : ID of Progressbar
; $ForeBmp : Handle to GDIplus -image or -bitmap , -1 To leave the old
; The foreground image
; $BackBmp : [Optional] Handle to GDIplus -image or -bitmap , -1 To leave the old
; The background image
; Requirement(s): Winapi.au3, GDIplus
; Return Value(s): Success: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSetText(
; Description:: Sets the text to be shown
; Parameter(s): $ID : ID of Progressbar
; $text: -> TRUE : Show percent
; -> A string to be shown, %P% is replaced with Percentage
; Requirement(s): This UDf
; Return Value(s): Success: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSetFont()
; Description:: Sets the Font and Color of the Text of the Progressbar
; Parameter(s): $ID : ID of Progressbar
; $Font : Name of the font (empty String "" to do not change)
; $size : [Optional] size of the font ( 0 or negative to leave the old)
; $Styles : [Optional] The style of the typeface. Can be a combination of the following:
; 0 - Normal weight or thickness of the typeface
; 1 - Bold typeface
; 2 - Italic typeface
; 4 - Underline
; 8 - Strikethrough
; ( -1, negative to leave the old)
; $ARGBcolor : [Optional] the color of the font, can be RGB or ARGB (depending on $isARGB)
; (empty String "" to do not change)
; $isARGB : [Optional] Sets, whether $ARGBcolor is RGB (False, default) or ARGB (True)
; Requirement(s): This UDF
; Return Value(s): Success: 1, Error: 0
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressSet()
; Description:: Sets the percentage of the Progressbar
; Parameter(s): $ID : ID of Progressbar
; $prc The percentage to set
; Requirement(s): This UDF
; Return Value(s): If Progressbar odes not Exist: @error is set to 1
; Author(s): Prog@ndy
;
;===============================================================================
;
;===============================================================================
;
; Function Name: _ProgressMarquee()
; Description:: Sets the
; Parameter(s): $ID : ID of Progressbar
; $speed : The speed of the Marquee: 1 to 10, smaller as 1 turns it off
; $makeSmallFront : Crop the Front image to 1/10 of its former width
; If it was created by _ProgressSetColors, this is 1/10 of Progress Width
; If this is set to -1 and $speed is set to < 0 then the Front image size is
; set to the width of the Progressbar
; Requirement(s): WinAPI
; Return Value(s): If Progressbar does not Exist: @error is set to 1
; Author(s): Prog@ndy
;
;===============================================================================
;
Spoiler anzeigen
#include <GDIpProgress.au3>
;##################################
; EXAMPLE
#Region EXAMPLE
$Gui = GUICreate("Gradient ProgressBar", 400, 350)
[/autoit] [autoit][/autoit] [autoit];Progress 1 + Controls
$slid = GUICtrlCreateSlider(5, 20, 310, 30) ;; check only for first bar
$Status_Label = GUICtrlCreateLabel("0%", 330, 30, 30, 20)
$btn_0 = GUICtrlCreateButton("0", 2, 100, 15, 25, 0)
$btn_25 = GUICtrlCreateButton("25", 20, 100, 75, 25, 0)
$btn_50 = GUICtrlCreateButton("50", 120, 100, 75, 25, 0)
$btn_75 = GUICtrlCreateButton("75", 220, 100, 75, 25, 0)
$btn_cl1 = GUICtrlCreateButton("Colors 1", 20, 140, 75, 25, 0)
$btn_cl2 = GUICtrlCreateButton("Colors 2", 220, 140, 75, 25, 0)
$btn_vistOK = GUICtrlCreateButton("Vista OK", 220, 180, 75, 25, 0)
$btn_vistError = GUICtrlCreateButton("Vista Error", 220, 210, 75, 25, 0)
$btn_vistPause = GUICtrlCreateButton("Vista Pause", 220, 240, 75, 25, 0)
$btn_txt = GUICtrlCreateButton("Set Text", 100, 180, 75, 25, 0)
$in_txt = GUICtrlCreateInput("%P%", 20, 180, 75, 25, 0)
GUICtrlSetTip(-1, "Use %P% to show Percentage" & @CRLF & "Leave empty to show no text")
$sID = _ProgressCreate(10, 60, 300, 40)
_ProgressSetText($sID, "Install %P%%")
; End Progress 1 + Controls
[/autoit] [autoit][/autoit] [autoit];Progress 2 + Controls
$Progress2 = _ProgressCreate(10, 280, 300, 20)
_ProgressSet($Progress2, 43)
$input = GUICtrlCreateInput("43", 320, 280, 50, 20, $ES_NUMBER)
GUICtrlSetLimit($input, 3, 1)
$updown = GUICtrlCreateUpdown($input)
GUICtrlSetLimit($updown, 100, 0)
;End Progress 2 + Controls
;Progress Marquee + Controls
$PMarquee = _ProgressCreate(10, 310, 300, 30)
_ProgressSetImages($PMarquee, @ScriptDir & "\prgimgs\marquee.jpg", @ScriptDir & "\prgimgs\bg.jpg")
_ProgressMarquee($PMarquee, 2, 0)
$marVist = GUICtrlCreateCheckbox("Vista Style",315,315,100,20)
GUICtrlSetState(-1,$GUI_CHECKED)
;End Progress Marquee + Controls
GUISetState()
[/autoit] [autoit][/autoit] [autoit]While 1
[/autoit] [autoit][/autoit] [autoit]$nMsg = GUIGetMsg()
Switch $nMsg
Case $btn_0
_ProgressSet($sID, 0)
GUICtrlSetData($slid, 0)
Case $btn_25
_ProgressSet($sID, 25)
GUICtrlSetData($slid, 25)
Case $btn_50
_ProgressSet($sID, 50)
GUICtrlSetData($slid, 50)
Case $btn_75
_ProgressSet($sID, 75)
GUICtrlSetData($slid, 75)
Case $btn_cl1
_ProgressSetColors($sID, 0xFF0000, 0x00FF00, 0xA1B0BB, 0x4455FF)
_ProgressSetFont($sID, "", -1, -1, 0xFFBBBBFF, True)
Case $btn_cl2
_ProgressSetColors($sID, 0x89A49B, 0xF0D6C7, 0xFFFFFF, 0xFFFFFF)
_ProgressSetFont($sID, "", -1, -1, 0x000000)
Case $btn_vistOK
_ProgressSetImages($sID, @ScriptDir & "\prgimgs\green.jpg", @ScriptDir & "\prgimgs\bg.jpg")
_ProgressSetFont($sID, "", -1, -1, 0x0000FF)
Case $btn_vistPause
_ProgressSetImages($sID, @ScriptDir & "\prgimgs\yellow.jpg", @ScriptDir & "\prgimgs\bg.jpg")
_ProgressSetFont($sID, "", -1, -1, 0xFF0000)
Case $btn_vistError
_ProgressSetImages($sID, @ScriptDir & "\prgimgs\red.jpg", @ScriptDir & "\prgimgs\bg.jpg")
_ProgressSetFont($sID, "", -1, -1, 0x000000)
Case $btn_txt
_ProgressSetText($sID, GUICtrlRead($in_txt))
Case $input, $updown
_ProgressSet($Progress2, GUICtrlRead($input))
Case $marVist
If BitAND(GUICtrlRead($marVist),$GUI_CHECKED) = $GUI_CHECKED Then
_ProgressSetImages($PMarquee, @ScriptDir & "\prgimgs\marquee.jpg", @ScriptDir & "\prgimgs\bg.jpg")
Else
_ProgressSetColors($PMarquee, 0xFFFF00, 0x00FF00, 0xAAAA00, 0xFF0000)
_ProgressMarquee($PMarquee, 2, 1)
EndIf
Case $GUI_EVENT_CLOSE
_ProgressDelete($sID) ; MUST BE DONE ON EXIT
_Progress_CallBack_Free(1) ; Force Killing Timer
_GDIPlus_Shutdown()
[/autoit] [autoit][/autoit] [autoit]Exit
EndSwitch
If $iPercent <> GUICtrlRead($slid) Then
$iPercent = GUICtrlRead($slid)
GUICtrlSetData($Status_Label, $iPercent & "%")
_ProgressSet($sID, $iPercent)
EndIf
WEnd
[/autoit]Changelog
- 16.6.08
- Beispiel abgetrennt
- Marquee hinzugefügt
- 20.7.08
- Fehler in _ProgressDelete berichtigt
//Edit: Bild:
Spoiler anzeigen
Vorige Downloads: 42
Download ab jetzt hier: DOWNLOAD