Sign in to follow this  
Followers 0
Noobcube

progress bar

8 posts in this topic

how do i make a simple look with a progress bar filling up, empting and repeating

thanks im advance

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

how do i make a simple look with a progress bar filling up, empting and repeating

thanks im advance

GUICtrlCreateProgress

Or do you mean a custom one?

This is kind of junk. But I was playing with GDI stuff the other day:

#include <GUIConstants.au3>
#include <GDIPlus.au3>
;
Global $hGraphics
$MainGUI = GUICreate("Form1", 625, 445, 193, 125)
GUISetState(@SW_SHOW)
$Progress = _GUICtrlCreateProgress($MainGUI, 200, 100, 300, 20)


_GUICtrlSetProgress($Progress, 0x9EFF0011, 9.8)
Sleep(1000)
_GUICtrlSetProgress($Progress, 0x9E0000F1, 122.8)
Sleep(1000)
_GUICtrlSetProgress($Progress, 0x9E0000F1, 50)
Sleep(1000)

For $I = 1 to 10
    _GUICtrlSetProgress($Progress, 0x9E0000F1, Int($I))
    Sleep(200)
    TrayTip("Progress", $I, 1)
Next




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _GUICtrlSetProgress($aRet, $iARGB, $dPercent, $HOffset = .5)
    Local $hGUI = $aRet[0]
    Local $iX = $aRet[1] + 1
    Local $iY = $aRet[2]
    Local $iWidth = Round(($aRet[3] * ($dPercent / 100)), 2) - 1
    Local $iHeight = $aRet[4]
    Local $aFact[4]  = [0.0, 0.0, 0.2, 1.0] ; 0. .2 .4 1.
    Local $aPosit[4] = [0.0, 0.0, 0.0, 1.0]
    
    If $iWidth > $aRet[3] Then $iWidth = $aRet[3] - 1
    
    $hWhiteBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $aRet[3] - 1, $iHeight - 1, $hWhiteBrush)
    $hBrushLin1 = GDIPlus_CreateLineBrushFromRect(1, $iHeight * $HOffset, $iWidth / 2, ($iHeight / 2) + 1, $aFact, $aPosit, _
                                                    0xBF000000, 0xCFDDDDDD, 0x00000001, 3)
    ;

    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hBrushLin1) ; x/y pos. width height
    $hBrush2 = _GDIPlus_BrushCreateSolid($iARGB)
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $iWidth, $iHeight - 1, $hBrush2)

    
EndFunc



Func _GUICtrlCreateProgress($hGUI, $iX, $iY, $iWidth, $iHeight)
    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hWhiteBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    ;$hBrushLin1 = GDIPlus_CreateLineBrushFromRect(1, $iHeight * $HOffset, $iWidth / 2, ($iHeight / 2) + 1, $aFact, $aPosit, _
    ;                                               0xBF000000, 0xCFDDDDDD, 0x00000001, 3)
    ;
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hWhiteBrush)
    _GDIPlus_GraphicsDrawRect($hGraphics, $iX, $iY, $iWidth, $iHeight)
    ;_GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hBrushLin1) ; x/y pos. width height
    ;$hBrush2 = _GDIPlus_BrushCreateSolid(0x9E001188)
    ;_GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $iWidth, $iHeight - 1, $hBrush2)
    Local $aRet[5]
        $aRet[0] = $hGUI
        $aRet[1] = $iX
        $aRet[2] = $iY
        $aRet[3] = $iWidth
        $aRet[4] = $iHeight
    Return $aRet

EndFunc

;==== GDIPlus_CreateLineBrushFromRect ===
;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.
; $aFactors - If non-array, default array will be used.
;           Pointer to an array of real numbers that specify blend factors. Each number in the array
;           specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.
;$aPositions - If non-array, default array will be used.
;            Pointer to an array of real numbers that specify blend factors' positions. Each number in the array
;            indicates a percentage of the distance between the starting boundary and the ending boundary
;            and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the
;            gradient and 1.0 indicates the ending boundary. There must be at least two positions
;            specified: the first position, which is always 0.0, and the last position, which is always
;            1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a
;            line, parallel to the boundary lines, that is a certain fraction of the distance from the
;            starting boundary to the ending boundary. For example, a blend position of 0.7 indicates
;            the line that is 70 percent of the distance from the starting boundary to the ending boundary.
;            The color is constant on lines that are parallel to the boundary lines.
; $iArgb1    - First Top color in 0xAARRGGBB format
; $iArgb2    - Second color in 0xAARRGGBB format
; $LinearGradientMode -  LinearGradientModeHorizontal       = 0x00000000,
;                        LinearGradientModeVertical         = 0x00000001,
;                        LinearGradientModeForwardDiagonal  = 0x00000002,
;                        LinearGradientModeBackwardDiagonal = 0x00000003
; $WrapMode  - WrapModeTile       = 0,
;              WrapModeTileFlipX  = 1,
;              WrapModeTileFlipY  = 2,
;              WrapModeTileFlipXY = 3,
;              WrapModeClamp      = 4
; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,
;             LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)
; Reference:  http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx
;
Func GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
        $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

    If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF
    If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000
    If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001
    If $WrapMode = -1 Then $WrapMode = 1

    $tRect = DllStructCreate("float X;float Y;float Width;float Height")
    $pRect = DllStructGetPtr($tRect)
    DllStructSetData($tRect, "X", $iX)
    DllStructSetData($tRect, "Y", $iY)
    DllStructSetData($tRect, "Width", $iWidth)
    DllStructSetData($tRect, "Height", $iHeight)

    ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined
    $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
            "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

    If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
    If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

    $iCount = UBound($aPositions)
    $tFactors = DllStructCreate("float[" & $iCount & "]")
    $pFactors = DllStructGetPtr($tFactors)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
    Next
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
    Next

    $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
            "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
    Return $aRet[6] ; Handle of Line Brush
EndFunc   ;==>GDIPlus_CreateLineBrushFromRect
Edited by Szhlopp

Share this post


Link to post
Share on other sites

You could also use this GDIplus-Progressbar: http://www.autoitscript.com/forum/index.ph...=74649&st=0


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

GUICtrlCreateProgress

Or do you mean a custom one?

This is kind of junk. But I was playing with GDI stuff the other day:

#include <GUIConstants.au3>
#include <GDIPlus.au3>
;
Global $hGraphics
$MainGUI = GUICreate("Form1", 625, 445, 193, 125)
GUISetState(@SW_SHOW)
$Progress = _GUICtrlCreateProgress($MainGUI, 200, 100, 300, 20)


_GUICtrlSetProgress($Progress, 0x9EFF0011, 9.8)
Sleep(1000)
_GUICtrlSetProgress($Progress, 0x9E0000F1, 122.8)
Sleep(1000)
_GUICtrlSetProgress($Progress, 0x9E0000F1, 50)
Sleep(1000)

For $I = 1 to 10
    _GUICtrlSetProgress($Progress, 0x9E0000F1, Int($I))
    Sleep(200)
    TrayTip("Progress", $I, 1)
Next




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _GUICtrlSetProgress($aRet, $iARGB, $dPercent, $HOffset = .5)
    Local $hGUI = $aRet[0]
    Local $iX = $aRet[1] + 1
    Local $iY = $aRet[2]
    Local $iWidth = Round(($aRet[3] * ($dPercent / 100)), 2) - 1
    Local $iHeight = $aRet[4]
    Local $aFact[4]  = [0.0, 0.0, 0.2, 1.0] ; 0. .2 .4 1.
    Local $aPosit[4] = [0.0, 0.0, 0.0, 1.0]
    
    If $iWidth > $aRet[3] Then $iWidth = $aRet[3] - 1
    
    $hWhiteBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $aRet[3] - 1, $iHeight - 1, $hWhiteBrush)
    $hBrushLin1 = GDIPlus_CreateLineBrushFromRect(1, $iHeight * $HOffset, $iWidth / 2, ($iHeight / 2) + 1, $aFact, $aPosit, _
                                                    0xBF000000, 0xCFDDDDDD, 0x00000001, 3)
    ;

    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hBrushLin1) ; x/y pos. width height
    $hBrush2 = _GDIPlus_BrushCreateSolid($iARGB)
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $iWidth, $iHeight - 1, $hBrush2)

    
EndFunc



Func _GUICtrlCreateProgress($hGUI, $iX, $iY, $iWidth, $iHeight)
    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hWhiteBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    ;$hBrushLin1 = GDIPlus_CreateLineBrushFromRect(1, $iHeight * $HOffset, $iWidth / 2, ($iHeight / 2) + 1, $aFact, $aPosit, _
    ;                                               0xBF000000, 0xCFDDDDDD, 0x00000001, 3)
    ;
    _GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hWhiteBrush)
    _GDIPlus_GraphicsDrawRect($hGraphics, $iX, $iY, $iWidth, $iHeight)
    ;_GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY, $iWidth, $iHeight, $hBrushLin1) ; x/y pos. width height
    ;$hBrush2 = _GDIPlus_BrushCreateSolid(0x9E001188)
    ;_GDIPlus_GraphicsFillRect($hGraphics, $iX, $iY + 1, $iWidth, $iHeight - 1, $hBrush2)
    Local $aRet[5]
        $aRet[0] = $hGUI
        $aRet[1] = $iX
        $aRet[2] = $iY
        $aRet[3] = $iWidth
        $aRet[4] = $iHeight
    Return $aRet

EndFunc

;==== GDIPlus_CreateLineBrushFromRect ===
;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.
; $aFactors - If non-array, default array will be used.
;           Pointer to an array of real numbers that specify blend factors. Each number in the array
;           specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.
;$aPositions - If non-array, default array will be used.
;            Pointer to an array of real numbers that specify blend factors' positions. Each number in the array
;            indicates a percentage of the distance between the starting boundary and the ending boundary
;            and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the
;            gradient and 1.0 indicates the ending boundary. There must be at least two positions
;            specified: the first position, which is always 0.0, and the last position, which is always
;            1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a
;            line, parallel to the boundary lines, that is a certain fraction of the distance from the
;            starting boundary to the ending boundary. For example, a blend position of 0.7 indicates
;            the line that is 70 percent of the distance from the starting boundary to the ending boundary.
;            The color is constant on lines that are parallel to the boundary lines.
; $iArgb1    - First Top color in 0xAARRGGBB format
; $iArgb2    - Second color in 0xAARRGGBB format
; $LinearGradientMode -  LinearGradientModeHorizontal       = 0x00000000,
;                        LinearGradientModeVertical         = 0x00000001,
;                        LinearGradientModeForwardDiagonal  = 0x00000002,
;                        LinearGradientModeBackwardDiagonal = 0x00000003
; $WrapMode  - WrapModeTile       = 0,
;              WrapModeTileFlipX  = 1,
;              WrapModeTileFlipY  = 2,
;              WrapModeTileFlipXY = 3,
;              WrapModeClamp      = 4
; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,
;             LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)
; Reference:  http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx
;
Func GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
        $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

    If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF
    If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000
    If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001
    If $WrapMode = -1 Then $WrapMode = 1

    $tRect = DllStructCreate("float X;float Y;float Width;float Height")
    $pRect = DllStructGetPtr($tRect)
    DllStructSetData($tRect, "X", $iX)
    DllStructSetData($tRect, "Y", $iY)
    DllStructSetData($tRect, "Width", $iWidth)
    DllStructSetData($tRect, "Height", $iHeight)

    ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined
    $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
            "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

    If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
    If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

    $iCount = UBound($aPositions)
    $tFactors = DllStructCreate("float[" & $iCount & "]")
    $pFactors = DllStructGetPtr($tFactors)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
    Next
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
    Next

    $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
            "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
    Return $aRet[6] ; Handle of Line Brush
EndFunc   ;==>GDIPlus_CreateLineBrushFromRect

like that only a lot simpler lol

i tried http://www.autoitscript.com/forum/index.ph...=74649&st=0

but doesnt work on my pc :/

Share this post


Link to post
Share on other sites

What's the point in a progress bar that doesn't actually indicate progress? If you just want to indicate something is being done, use a "throbber" instead. You know like the little icon that spins or pulses or whatever when your web browser is downloading a page.

Share this post


Link to post
Share on other sites

long story lol

i just want it to look like its doing something lol

Share this post


Link to post
Share on other sites

That's why a throbber would be more efficient. It's much easier to make too, just use an animated image.

Share this post


Link to post
Share on other sites

Hi Noobcube,

Doing a search of your topic, it's been found many times with the search feature or is listed as a non-descriptive topic.

Please do a search before posting new thread topics.

And please use descriptive topics so that others that do use the search feature may also find what they are seeking.

(You'll also find that using descriptive topics, will get people in your thread that know how to answer your questions, those same people ignore non-descriptive topics).

Thanks.

Share this post


Link to post
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
Sign in to follow this  
Followers 0