Jump to content

Recommended Posts

Posted (edited)

Thanks for your comments.

 

Added 6 more animations - just checkout my 1st post.

 

Thanks to Eukalyptus for providing an additional example (_GDIPlus_GlowingText.au3)!  :thumbsup:

 

Maybe some more examples will follow...  :shifty:

 

Br,

UEZ 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

This is on of my top favorite topics on the forums! amazing work, really!

I managed to add the Rotating Bokeh to my script by using removing:

If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
 $iPerc += 0.1
If $iPerc > 99.9 Then $iPerc = 0

And a couple more lines.

It lost the background and got replaced with a solid color one, the circles in the middle started leaving a trace behind them "which IMO made it look even cooler", however the same thing doesn't apply to LineProgressBar.

How do I make it that once $iPerc > 100 the function would exit and my script would start?

Posted (edited)

With a small modification you can replace the bitmap background with a solid color easily and the way I play the animation is only an example.

 

In real environment you will do it probably slightly different.

 

Without seeing your code I cannot say how to exit the animation. If you used the same way I have used then just have a look to the $GUI_EVENT_CLOSE section.

 

Btw, removing

If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
from the loop may cause a memory leak!

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

With a small modification you can replace the bitmap background with a solid color easily and the way I play the animation is only an example.

 

In real environment you will do it probably slightly different.

 

Without seeing your code I cannot say how to exit the animation. If you used the same way I have used then just have a look to the $GUI_EVENT_CLOSE section.

 

Btw, removing

If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
from the loop may cause a memory leak!

 

Br,

UEZ

 

 

Thank you for the heads up on the memory leak issue, I adjusted the loading process speed, changed the animation of the progress bar a tiny bit, and made the loading seem slower at 90%.

I tried few things such as setting the GUI state to hide, deleting the GUI, exiting, calling my function at 100%, none of them worked, I placed the progress bar and its function after the includes in my script and right before my own function, I tried adding it after my function and calling it, that didn't work either, my script is around +3650 lines (still trying to figure out how to make it shorter but I always end up making it bigger by adding more functions to it), and got a lot of info that can't be shared publicly, so I can't simply post the code or part of it here except the following:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GUIEdit.au3>
#include <Clipboard.au3>
#include <MsgBoxConstants.au3>
#include <GDIPlus.au3>
#include <Memory.au3>
#include <Misc.au3>
#include <DateTimeConstants.au3>
#include <File.au3>
#include <ColorConstants.au3>
 

;~ **** Progress bar function goes here

Opt("TrayMenuMode", 3)

RAIS()

Func RAIS()
    Local $iServices = TrayCreateMenu("Services")
    Local $iLogin = TrayCreateItem("Login", $iServices)
    Local $iDataEntry = TrayCreateItem("Data Entry", $iServices)

    TrayCreateItem("")
    Local $LSettings = TrayCreateItem("Login Settings")
    Local $DSettings = TrayCreateItem("Default Settings")
    Local $iAbout = TrayCreateItem("About")
    TrayCreateItem("")
    Local $iExit = TrayCreateItem("Exit")
    TraySetIcon($icon)
    TraySetState(1)
Edited by Palestinian
Posted (edited)

You can do something like this here?

;coded by UEZ build 2013-05-02, idea taken from http://tympanus.net/codrops/2012/11/14/creative-css-loading-animations/
;AutoIt v3.3.9.21 or higher needed!
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iPerc, $iPic, $hHBmp_BG, $hB, $iSleep = 20, $iW = 400, $iH = 210

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Test", 615, 438)
GUISetBkColor(0x808080)
$TEST = GUICtrlCreateLabel("TEST", 40, 0, 547, 261)
GUICtrlSetFont(-1, 160, 400, 0, "Verdana")
$Button1 = GUICtrlCreateButton("Start Download", 32, 296, 99, 81)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
        Case $Button1
            $iPerc = 0
            $iAngle = 0
            WaitingAnim()
    EndSwitch
WEnd

Exit


Func WaitingAnim()
    Local Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    GUISetBkColor(0)
    $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        $iPerc += 3 ;your progress should be place here
        If $iPerc > 99 Then ExitLoop
    Until Not Sleep(100)

    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    GUIDelete($hGUI)
EndFunc


Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, "Please wait..." & StringFormat("%05.2f %", $iPerc))
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
EndFunc   ;==>PlayAnim

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $iBGColor = 0xFF202020, $bHBitmap = True)
    Local Const $hBrushBall1 = _GDIPlus_BrushCreateSolid(0xE004AC6B)
    Local Const $hBrushBall2 = _GDIPlus_BrushCreateSolid(0xC0E0AB27)
    Local Const $hBrushBall3 = _GDIPlus_BrushCreateSolid(0xD081B702)
    Local Const $hBrushBall4 = _GDIPlus_BrushCreateSolid(0xB0E70339)
    Local Const $hPen = _GDIPlus_PenCreate(0xFF303030)
    DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "handle", $hPen, "int", 2)
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", $GDIP_PXF32ARGB, "ptr", 0, "int*", 0)
    $hBitmap = $hBitmap[6]

    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsClear($hCtxt, $iBGColor)
    Local Const $fDeg = ACos(-1) / 180, $iRadius = 40, $iBallSize = $iRadius / 1.77, $iCircleSize = $iBallSize + 2 * $iRadius, $iBallSize2 = $iBallSize / 2, _
            $iCircleSize2 = $iCircleSize / 2, $fFontSize = 11, $iW2 = -1 + $iW / 2, $iH2 = -1 + $iH / 2
    DllCall($ghGDIPDll, "int", "GdipDrawEllipse", "handle", $hCtxt, "handle", $hPen, "float", $iW2 - $iCircleSize2, "float", $iH2 - $iCircleSize2, "float", $iCircleSize, "float", $iCircleSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall1, "float", -$iBallSize2 + $iW2 + Cos(2.25 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(2.25 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall2, "float", -$iBallSize2 + $iW2 + Cos(1.75 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.75 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall3, "float", -$iBallSize2 + $iW2 + Cos(1.66 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.66 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall4, "float", -$iBallSize2 + $iW2 + Cos(1.33 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.33 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    $iAngle += 2.5

    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, 2)
    Local Const $hBrushTxt = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hCtxt, $sString, $hFont, $tLayout, $hFormat)
    DllStructSetData($tLayout, "X", ($iW - DllStructGetData($aInfo[0], "Width")) / 2)
    DllStructSetData($tLayout, "Y", $iH / 2 + $iRadius + $iBallSize)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sString, $hFont, $tLayout, $hFormat, $hBrushTxt)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrushTxt)

    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_BrushDispose($hBrushBall1)
    _GDIPlus_BrushDispose($hBrushBall2)
    _GDIPlus_BrushDispose($hBrushBall3)
    _GDIPlus_BrushDispose($hBrushBall4)
    _GDIPlus_PenDispose($hPen)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_RotatingBokeh
Btw, who's that on your avatar?

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

You can do something like this here?

;coded by UEZ build 2013-05-02, idea taken from http://tympanus.net/codrops/2012/11/14/creative-css-loading-animations/
;AutoIt v3.3.9.21 or higher needed!
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iPerc, $iPic, $hHBmp_BG, $hB, $iSleep = 20, $iW = 400, $iH = 210

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Test", 615, 438)
GUISetBkColor(0x808080)
$TEST = GUICtrlCreateLabel("TEST", 40, 0, 547, 261)
GUICtrlSetFont(-1, 160, 400, 0, "Verdana")
$Button1 = GUICtrlCreateButton("Start Download", 32, 296, 99, 81)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
        Case $Button1
            $iPerc = 0
            $iAngle = 0
            WaitingAnim()
    EndSwitch
WEnd

Exit


Func WaitingAnim()
    Local Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    GUISetBkColor(0)
    $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        $iPerc += 3 ;your progress should be place here
        If $iPerc > 99 Then ExitLoop
    Until Not Sleep(100)

    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    GUIDelete($hGUI)
EndFunc


Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, "Please wait..." & StringFormat("%05.2f %", $iPerc))
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
EndFunc   ;==>PlayAnim

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $iBGColor = 0xFF202020, $bHBitmap = True)
    Local Const $hBrushBall1 = _GDIPlus_BrushCreateSolid(0xE004AC6B)
    Local Const $hBrushBall2 = _GDIPlus_BrushCreateSolid(0xC0E0AB27)
    Local Const $hBrushBall3 = _GDIPlus_BrushCreateSolid(0xD081B702)
    Local Const $hBrushBall4 = _GDIPlus_BrushCreateSolid(0xB0E70339)
    Local Const $hPen = _GDIPlus_PenCreate(0xFF303030)
    DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "handle", $hPen, "int", 2)
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", $GDIP_PXF32ARGB, "ptr", 0, "int*", 0)
    $hBitmap = $hBitmap[6]

    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsClear($hCtxt, $iBGColor)
    Local Const $fDeg = ACos(-1) / 180, $iRadius = 40, $iBallSize = $iRadius / 1.77, $iCircleSize = $iBallSize + 2 * $iRadius, $iBallSize2 = $iBallSize / 2, _
            $iCircleSize2 = $iCircleSize / 2, $fFontSize = 11, $iW2 = -1 + $iW / 2, $iH2 = -1 + $iH / 2
    DllCall($ghGDIPDll, "int", "GdipDrawEllipse", "handle", $hCtxt, "handle", $hPen, "float", $iW2 - $iCircleSize2, "float", $iH2 - $iCircleSize2, "float", $iCircleSize, "float", $iCircleSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall1, "float", -$iBallSize2 + $iW2 + Cos(2.25 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(2.25 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall2, "float", -$iBallSize2 + $iW2 + Cos(1.75 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.75 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall3, "float", -$iBallSize2 + $iW2 + Cos(1.66 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.66 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    DllCall($ghGDIPDll, "int", "GdipFillEllipse", "handle", $hCtxt, "handle", $hBrushBall4, "float", -$iBallSize2 + $iW2 + Cos(1.33 * $iAngle * $fDeg) * $iRadius, "float", -$iBallSize2 + $iH2 + Sin(1.33 * $iAngle * $fDeg) * $iRadius, "float", $iBallSize, "float", $iBallSize)
    $iAngle += 2.5

    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, 2)
    Local Const $hBrushTxt = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hCtxt, $sString, $hFont, $tLayout, $hFormat)
    DllStructSetData($tLayout, "X", ($iW - DllStructGetData($aInfo[0], "Width")) / 2)
    DllStructSetData($tLayout, "Y", $iH / 2 + $iRadius + $iBallSize)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sString, $hFont, $tLayout, $hFormat, $hBrushTxt)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrushTxt)

    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_BrushDispose($hBrushBall1)
    _GDIPlus_BrushDispose($hBrushBall2)
    _GDIPlus_BrushDispose($hBrushBall3)
    _GDIPlus_BrushDispose($hBrushBall4)
    _GDIPlus_PenDispose($hPen)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_RotatingBokeh
Btw, who's that on your avatar?

 

Br,

UEZ

 

 

Thank you for the quick reply!

I'll try and implement your code into the LineProgressBar.

The guy in my avatar is my late dad, he passed away 2 months ago

Posted (edited)

The guy in my avatar is my late dad, he passed away 2 months ago

My condolences to you.  -_- May Allah rest his soul.

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

My condolences to you.  -_- May Allah rest his soul.

 

Br,

UEZ

 

Thank you for your kindness :)

I can't seem to get the code you posted to work with the the line progress bar, I'll just stick to the rotating bokeh, thank you again :)

Posted (edited)

Same technique with the line progress bar:
 

;coded by UEZ
;AutoIt v3.3.9.21 or higher needed!
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iPerc, $iPic, $hHBmp_BG, $hB, $iSleep = 20, $iW = 600, $iH = 250

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Test", 615, 438)
GUISetBkColor(0x808080)
$TEST = GUICtrlCreateLabel("TEST", 40, 0, 547, 261)
GUICtrlSetFont(-1, 160, 400, 0, "Verdana")
$Button1 = GUICtrlCreateButton("Start Download", 32, 296, 99, 81)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
        Case $Button1
            $iPerc = 0
            $iAngle = 0
            WaitingAnim()
    EndSwitch
WEnd

Exit


Func WaitingAnim()
    Local Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    GUISetBkColor(0)
    $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        $iPerc += 3 ;your progress should be place here
        If $iPerc > 99 Then ExitLoop
    Until Not Sleep(100)

    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    GUIDelete($hGUI)
EndFunc


Func PlayAnim()
    $hHBmp_BG = _GDIPlus_LineProgressbar($iPerc, $iW, $iH)
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
EndFunc   ;==>PlayAnim

Func _GDIPlus_LineProgressbar($fProgress, $iW, $iH, $sText = "Loading: ", $iColorLineProgressbar = 0xF02187E7, $sFont = "Segoe Script", $bHBitmap = True)
    Local $aColorPattern[4][4] = [[0xFF2A2A2A, 0xFF131313, 0xFF1A1A1A, 0xFF131313], _
                                  [0xFF1F1F1F, 0xFF1A1A1A, 0xFF131313, 0xFF1A1A1A], _
                                  [0xFF1A1A1A, 0xFF131313, 0xFF2A2A2A, 0xFF131313], _
                                  [0xFF131313, 0xFF1A1A1A, 0xFF1F1F1F, 0xFF1A1A1A]]
    Local Const $hBmp_texture = _GDIPlus_BitmapCreateFromScan0(4, 4)
    Local $iX, $iY
    For $iY = 0 To 3
        For $iX = 0 To 3
            _GDIPlus_BitmapSetPixel($hBmp_texture, $iX, $iY, $aColorPattern[$iY][$iX]) ;generate texture
        Next
    Next
    Local Const $hBrush_Texture = _GDIPlus_TextureCreate($hBmp_texture)
    _GDIPlus_BitmapDispose($hBmp_texture)
    Local Const $hBitmap  = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
;~  _GDIPlus_GraphicsSetSmoothingMode($hGfx, 5) ;smoothing doesn't look good for light effect
    _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_Texture)
    Local Const $iW2 = $iW / 2, $iH2 = $iH / 2, $iDY = 7, $hBrush_Bg = _GDIPlus_BrushCreateSolid(0x80000000), _
                $hBrush_Line = _GDIPlus_BrushCreateSolid($iColorLineProgressbar), _
                $hBrush_Light = _GDIPlus_LineBrushCreate(($iW * $fProgress / 100 + 2) / 2, 0, ($iW * $fProgress / 100 + 2) / 2, 15.6, 0x78000000 + BitAND($iColorLineProgressbar, 0x00A0A0F0), 0x10000000, 3)
    _GDIPlus_LineBrushSetLinearBlend($hBrush_Light, 0.45, 1)
    _GDIPlus_LineBrushSetGammaCorrection($hBrush_Light)
    _GDIPlus_GraphicsFillRect($hGfx, 0, $iH2 - 1, $iW, 3, $hBrush_Bg)
    Local $aPoints[6][2]
    $aPoints[0][0] = 5
    $aPoints[1][0] = 0
    $aPoints[1][1] = $iH2 - $iDY
    $aPoints[2][0] = $iW * $fProgress / 100 - 2
    $aPoints[2][1] = $iH2 - $iDY
    $aPoints[3][0] = $iW * $fProgress / 100 + 2
    $aPoints[3][1] = $iH2
    $aPoints[4][0] = $iW * $fProgress / 100 - 2
    $aPoints[4][1] = $iH2 + $iDY
    $aPoints[5][0] = 0
    $aPoints[5][1] = $iH2 + $iDY
    _GDIPlus_GraphicsFillPolygon($hGfx, $aPoints, $hBrush_Light)
    _GDIPlus_GraphicsFillRect($hGfx, 0, $iH2, $iW * $fProgress / 100, 1, $hBrush_Line)

    Local Const $hBitmap_Text = _GDIPlus_BitmapCreateFromScan0($iW, $iH2)
    Local Const $hGfx_Text = _GDIPlus_ImageGetGraphicsContext($hBitmap_Text)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Text, 4)

    Local Const $hPath = _GDIPlus_PathCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local Const $tLayout = _GDIPlus_RectFCreate(0, $iH / 8, $iW)
    Local Const $hBrush_Text = _GDIPlus_BrushCreateSolid(0xE0FFFFFF), $hPen_Text = _GDIPlus_PenCreate(0x80000000, 4)

    _GDIPlus_PathAddString($hPath, StringFormat($sText & " %02d%", $fProgress), $tLayout, $hFamily, 0, $iH / 10, $hFormat)
    _GDIPlus_GraphicsDrawPath($hGfx_Text, $hPath, $hPen_Text)
    _GDIPlus_GraphicsFillPath($hGfx_Text, $hPath, $hBrush_Text)
    _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Text, 0, $iH2, $iW, $iH2)

    _GDIPlus_GraphicsDispose($hGfx_Text)
    _GDIPlus_BitmapDispose($hBitmap_Text)

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_Line)
    _GDIPlus_BrushDispose($hBrush_Bg)
    _GDIPlus_BrushDispose($hBrush_Texture)
    _GDIPlus_BrushDispose($hBrush_Light)
    _GDIPlus_PenDispose($hPen_Text)
    _GDIPlus_GraphicsDispose($hGfx)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

I like to see these examples, because it helps me to learn how to paint with GDI+. However, most of these are (on my computer) very CPU intensive, using up to half of the CPU (thank God for dual-core processors, or it would be 100%). Is there any way (besides drastically slowing down the animation) to make these less CPU intensive? After all, if you are actually loading a program, and the CPU is being totally utilized for the loading animation, the loading process will be significantly slower.

Who else would I be?
Posted (edited)

Congratulation UEZ, very impressive coding and idea :)

 Thanks, the ideas are ripped from other web sites.  :whistle: 

 

I like to see these examples, because it helps me to learn how to paint with GDI+. However, most of these are (on my computer) very CPU intensive, using up to half of the CPU (thank God for dual-core processors, or it would be 100%). Is there any way (besides drastically slowing down the animation) to make these less CPU intensive? After all, if you are actually loading a program, and the CPU is being totally utilized for the loading animation, the loading process will be significantly slower.

Unfortunately graphical demonstrations like these ones are very CPU intensive because AutoIt is not designed to calculate fast enough to provide smooth animation with low CPU usage.

Most of the examples are using the $iSleep variable which defines the sleep time of the timer function. The higher the value is the slower the animation will be rendered and the CPU usage will be reduced. Impact: animation looks too slow.

I would like to know how many user here are using one or more examples in their programs.

I don't know how "readable" the code is to learn from GDI+. Most is more mathematic related rather than GDI+ techniques which are most time the same.

Thanks for your feedback.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Hi again,

Two little question please ^^

  • Can you explain me the purpose of this :   

           Global Const $STM_SETIMAGE = 0x0172;   ( tried to change 172, only this number seem working )

  • Can we have a transparent backgroung or changing the background color ?

 

Thanks !!

Posted

$STM_SETIMAGE = 0x0172 is the constant which is used within GUICtrlSendMsg() function to send the GDI image to the pic control. When you change this value it will fail. Check out: http://msdn.microsoft.com/en-us/library/windows/desktop/bb760782(v=vs.85).aspx

You can modify each function for your needs. E.g. if you need a flat color instead a textured background than modify it appropriatly (it's easy to do it).

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

 Thanks, the ideas are ripped from other web sites.  :whistle: 

 

Unfortunately graphical demonstrations like these ones are very CPU intensive because AutoIt is not designed to calculate fast enough to provide smooth animation with low CPU usage.

Most of the examples are using the $iSleep variable which defines the sleep time of the timer function. The higher the value is the slower the animation will be rendered and the CPU usage will be reduced. Impact: animation looks too slow.

I would like to know how many user here are using one or more examples in their programs.

I don't know how "readable" the code is to learn from GDI+. Most is more mathematic related rather than GDI+ techniques which are most time the same.

Thanks for your feedback.

Br,

UEZ

 

I implemented one of the animations in my little program, didn't do it for any actual loading process, only to show a co-worker that AutoIt CAN be pretty impressive and basically can do anything, after reading about it online for like 1 min he said it's hopeless to have anything that's actually helpful using it, the funny part is that he's the IT guy in our organization, lol...

  • 2 weeks later...
  • 4 weeks later...
Posted

These are awesome!!!!!!! haven't seen anything in autoit that comes close to looking as smart and smooth as this! Do you think these could be adapted for multiple installation type gui? Don't know how smooth it would be though for example

_GDIPlus_StripProgressbar Example1.au3

1-5% on tooltip text displays: Installing Adobe.. (does silent install in between.. shellexecute/run etc).

6-10% on tooltip text displays: Installing Java... (does silent install in between.. shellexecute/run etc).

11-15% on tooltip text displays: Creating shortcuts... (creates shortcuts etc..)

16-20% on tooltip text displays: Cleaning up... (delete some files/folders etc...

and so on

or even if the progress bar was like marquee style and the tooltip did the percent?

...or this the case of round peg/square hole?

 

Posted

These are awesome!!!!!!! haven't seen anything in autoit that comes close to looking as smart and smooth as this! Do you think these could be adapted for multiple installation type gui? Don't know how smooth it would be though for example

_GDIPlus_StripProgressbar Example1.au3

1-5% on tooltip text displays: Installing Adobe.. (does silent install in between.. shellexecute/run etc).

6-10% on tooltip text displays: Installing Java... (does silent install in between.. shellexecute/run etc).

11-15% on tooltip text displays: Creating shortcuts... (creates shortcuts etc..)

16-20% on tooltip text displays: Cleaning up... (delete some files/folders etc...

and so on

or even if the progress bar was like marquee style and the tooltip did the percent?

...or this the case of round peg/square hole?

 

You can do something like this here:

_GDIPlus_StripProgressbar Example1.au3

;coded by UEZ build 2013-08-15
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include "_GDIPlus_StripProgressbar.au3"

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF
Global Const $hGUI = GUICreate("Strip Progressbar", $iW, $iH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST)
GUISetBkColor($iBGColor)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 30, $hTooltip
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
Global $fPerc = 0, $aPos, $iPosX, $iPosY
Global $aColors[5][2] = [[0xFFEE5F5B, 0xFFF07673],[0xFFABCC04, 0xFFBBD636],[0xFF78CCEE, 0xFF93D6F1],[0xFFFFBB58, 0xFFFFC97A],[0xFFFF6677, 0xFFFF8795]]
Global $iRandom = Random(0, UBound($aColors) - 1, 1), $sText
$aPos = WinGetPos($hGUI)
$iPosX = $aPos[0]
$iPosY = $aPos[1] + $aPos[3]
Global $iColorTP = BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF), -16) + BitAND(0x0000FF00, $aColors[$iRandom][1]) + BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF0000), 16) ;convert to BGR


Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ToolTip("")
            GUIRegisterMsg($WM_TIMER, "")
            _WinAPI_DeleteObject($hHBmp_BG)
            _GDIPlus_Shutdown()
            GUIDelete()
            Exit
    EndSwitch
Until False


Func PlayAnim()
    Switch $fPerc
        Case 0 To 15
            $sText = "Installing Adobe..."
        Case 16 To 30
            $sText = "Installing Java..."
        Case 31 To 40
            $sText = "Creating shortcuts..."
        Case 41 To 60
            $sText = "Cleaning up..."
        Case 61 To 80
            $sText = "Configuring..."
        Case 81 To 99
            $sText = "Finalizing installations"
        Case 100
            $sText = "Finished"
    EndSwitch
    $hHBmp_BG = _GDIPlus_StripProgressbar($fPerc, $iW, $iH, 0xFF000000 + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], $sText)
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $fPerc += 0.15
    If $fPerc >= 100.5 Then
        $fPerc = 0
        $iRandom = Random(0, UBound($aColors) - 1, 1)
        $iColorTP = BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF), -16) + BitAND(0x0000FF00, $aColors[$iRandom][1]) + BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF0000), 16) ;convert to BGR
    EndIf
    ToolTip(StringFormat("%02d %", $fPerc), $iPosX + $fPerc / 100 * $iW - 1, $iPosY, "", "", 3)
    $hTooltip = WinGetHandle(StringFormat("%02d %", $fPerc))
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hTooltip, "wstr", "", "wstr", "")
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTooltip, "int", 0x0413, "int", $iColorTP, "int", 0) ;$TTM_SETTIPBKCOLOR = 0x0413
EndFunc   ;==>PlayAnim

The tooltip displays only the percentage.

If you have any question please ask.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
×
×
  • Create New...