Jump to content

GDI+ animated loading screens build 2014-06-20 (32 examples)


UEZ
 Share

Recommended Posts

Hey,

first of all thank you for this amazing work.

Is there a easy way to change the text (for the progressbar) while it keeps loading?

For example at 0%: Starting

at 50%: Loading assets

at:90%: Reading data

Something like this.

//Edit: SOlution found. Just another question:

If i set the progrss for example to 30 it jumps in one step. Is there a way to make is smoother?

Thank you!

Edited by TechnoMan
Link to comment
Share on other sites

I can add something like that to fill up the difference smoother but that can also be done outside the function when you call it. ;)

I will check it out whether I can implement it without redesigning the whole function.

 

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This is my crudely modified version that limits the progress bar to 10 seconds, to demonstrate one way of having its progress display elapsed time.

I'm sure when UEZ finds time he'll do it much more elegantly.

;originally 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 ;set width, height and background color of progress bar
Global Const $hGUI = GUICreate("Strip Progressbar", $iW, $iH, 801, 675, $WS_POPUPWINDOW, $WS_EX_TOPMOST) ; no border or other crhome
GUISetBkColor($iBGColor)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 30 ; $iSleep has effect on timing of progress bar as does $fPerc (not sure how to convert this to a predictable time duration)
Local $begin = TimerInit()
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
Global $fPerc = 0, $aPos, $iPosX, $iPosY
$aPos = WinGetPos($hGUI)
$iPosX = $aPos[0]
$iPosY = $aPos[1] + $aPos[3]

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_TIMER, "")
            _WinAPI_DeleteObject($hHBmp_BG)
            _GDIPlus_Shutdown()
            GUIDelete()
            Exit
    EndSwitch
    Sleep(1000)
    Local $dif = TimerDiff($begin)
;   ToolTip("$fPerc = " & int($fPerc) & @LF & "$dif = " & int($dif),$iPosX,$iPosY)
Until $dif > 10000
;ToolTip ("")
Exit

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_StripProgressbar($fPerc, $iW, $iH, 0xFF000000 + $iBGColor, 0xFFEE5F5B, 0xFFF07673, "IP Release/Renew")
    ;$hHBmp_BG = _GDIPlus_StripProgressbar($fPerc, $iW, $iH)
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $fPerc += .33
EndFunc   ;==>PlayAnim
Link to comment
Share on other sites

@timmy2: you can do it e.g. this way:

 

#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 = 20, $hTooltip

Global $fPerc = 0, $aPos, $iPosX, $iPosY
$aPos = WinGetPos($hGUI)
$iPosX = $aPos[0]
$iPosY = $aPos[1] + $aPos[3]
Global $iTimer = TimerInit(), $iSeconds = 10, $iMSeconds = $iSeconds * 1000

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

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _Exit()
    EndSwitch
Until False

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_StripProgressbar($fPerc, $iW, $iH, 0xFF000000 + $iBGColor, 0xFFEE5F5B, 0xFFF07673, "IP Release/Renew")
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $fPerc = TimerDiff($iTimer) / $iMSeconds * 100
    If $fPerc >= 100 Then
        _Exit()
    EndIf
    ToolTip(StringFormat("%.2f seconds", TimerDiff($iTimer) / 1000), $iPosX + $fPerc / 100 * $iW - 1, $iPosY, "", "", 3)
    $hTooltip = WinGetHandle(StringFormat("%02d %", $fPerc))
EndFunc   ;==>PlayAnim

Func _Exit()
    ToolTip("")
    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    _GDIPlus_Shutdown()
    GUIDelete()
    Exit
EndFunc

Btw, I reuploaded the archive from post#1 because _GDIPlus_StripProgressbar Example3.au3 was broken (sorry).

 

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 months later...

I know this is a fairly old topic, but anyways :)
I would like to know if i can change (or even better "hide-transparent") the background image on Bokeh example.

I've tried to set background color on image removed example but it failed. It's just plain black.

Thanks in advance :)

Link to comment
Share on other sites

"Old" is relative ;)

Try this:

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

;AutoIt version 3.3.8.0 or higher needed! Please update!

Global Const $hDwmApiDll = DllOpen("dwmapi.dll")
Global $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $bAero = DllStructGetData($sChkAero, 1)
Global $fStep = 0.02
If Not $bAero Then $fStep = 1.25

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172, $iTransCol = 0x555555
Global $iW = 400, $iH = 210
Global Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)

_WinAPI_SetLayeredWindowAttributes($hGUI, $iTransCol, 0xFF)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 20
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Global $z, $iPerc

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

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

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $bHBitmap = True, $bBgBmp = False, $bBgTransCol = 0xFFFFFFFF)
    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_GraphicsSetSmoothingMode($hCtxt, 2)
    If $bBgBmp Then
        Local Const $hBmp_BG = _GDIPlus_BMPFromMemory(_Background())
        Local $hBrushTexture = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "handle", $hBmp_BG, "int", 0, "int*", 3)
        $hBrushTexture = $hBrushTexture[3]
        _GDIPlus_BitmapDispose($hBmp_BG)
        _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrushTexture)
        _GDIPlus_BrushDispose($hBrushTexture)
    Else
        _GDIPlus_GraphicsClear($hCtxt, $bBgTransCol)
    EndIf

    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
    Local Static $iAngle = 0
    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

;==================================================================================================================================
; Function Name:         _GDIPlus_BMPFromMemory
; Description:            Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
;
; Parameters:            $bImage:    the binary string which contains any valid image which is supported by GDI+
; Optional:             $hHBITMAP:  if false a bitmap will be created, if true a hbitmap will be created
;
; Remark:               hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
;                       Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
;
; Requirement(s):        GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
; Return Value(s):        Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
;                       Error: 0
; Error codes:          1: $bImage is not a binary string
;                       2: unable to create stream on HGlobal
;                       3: unable to create bitmap from stream
;
; Author(s):            UEZ
; Additional Code:        thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
;                        Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
; Version:              v0.98 Build 2012-08-29 Beta
;===================================================================================================================================
Func _GDIPlus_BMPFromMemory($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image  saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory  ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count  associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
            "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
        Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBmp
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_BMPFromMemory

Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate('dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/windows/desktop/dd183381(v=vs.85).aspx
            'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
            'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
            'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
            'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
        DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
        $hResult = $hResult[0]
    Else
        $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
EndFunc   ;==>_WinAPI_BitmapCreateDIBFromBitmap

;Code below was generated by: 'File to Base64 String' Code Generator v1.12 Build 2013-03-27

Func _Background($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $Background
    $Background &= '/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wgARCAEAAQADASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECCP/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAec5YWahFEWABRALKCFgVAAsFgUAEUFglEWFQUEKEFlgBUogFpAEFlCWFQUCAsoIUEAABQRYLKEBQShYRQBALAAKZtgUJYUgoSoAFgspYhZYFEKRYWUSwFhQAACFgUhYCwWWAAACwUAhZYVAWAAAAAhQAALKIFlhqIUCURqEUQpFEKRRmgBZYFgspAWAKQ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X/sz39wQhX59JYq2Yv5jbuoBT6MRiDE/Woo4NzzgLXHMGeYeTKoS5dL6SzFdxwcMXinfUEnr'
    $Background &= 'G86ltb46g01fM7u5dOL3KyYID01ELYyLM/zxBP8AyK3J9TSQWgrTuIGSWEUZ/wAnLjmDtQ5lA60QIVliWNeEtaPPUwRY+05CNRZpG425V32EKzhnL0Jnh+o6ZjaOY4QY+DjEsUy/ca764gW7N9RO+2Axg+PMKsxxMFtcfmdD9LKF13+ILFH2SgTWXsluGSXMKyO4WlXOwzqGWeUotv5nLaAfCCwUGjcxXIZiq8kzYntF+ZioljC9js6jeqa6iILcbEzG1EbeWI7t0xKT0gMa4gVqtzsSFHiGBnp17xNlqKToK+2W4y8/iWhhfiXhbz1NmoZcQN5rfcbQtPmG8pfrDWjfc//Z'
    Local $bString = Binary(_Base64Decode($Background))
    If $bSaveBinary Then
        Local $hFile = FileOpen($sSavePath & "\stressed_linen.jpg", 18)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_Background

Func _Base64Decode($sB64String)
    Local $a_Call = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & $a_Call[5] & "]")
    $a_Call = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $a, "dword*", $a_Call[5], "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks works as intended! I don't know if my love for you will ever end :)

 

Can i set my own color with opacity as background? if so how :)

If you want to change only the background then remove the code for transparency and use this line instead

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, "Please wait..." & StringFormat("%05.2f %", $iPerc), 1, 0, 0xFF405050)

It will change the background color.

 

Btw, are you a male or a female? 

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

If you want to change only the background then remove the code for transparency and use this line instead

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, "Please wait..." & StringFormat("%05.2f %", $iPerc), 1, 0, 0xFF000000 + 0x405050)

It will change the background color.

 

Btw, are you a male or a female? 

Br,

UEZ

male. Hahah. My love for you is "bromance" i believe ;)

Ps: Which line should i remove. Sorry no idea how to use GDI+ (I hope this is not an insult to you. Kudos man, kudos.)

Edited by continyu
Link to comment
Share on other sites

Something like this here:

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

;AutoIt version 3.3.8.0 or higher needed! Please update!

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172, $iBgColor = 0xFF405050
Global $iW = 400, $iH = 210
Global Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 20
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Global $iPerc

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

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

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $bHBitmap = True, $bBgCol = 0xFFFFFFFF)
    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_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsClear($hCtxt, $bBgCol)

    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
    Local Static $iAngle = 0
    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

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Ok, got it now :) for the last time;

Can i use elipse for background fill instead of rectangle? It seems like it's an easy fix (i tried to remove fillrect and add ellipse gdi func. but rect still appears and there is no ellipse :/ )

And anyways, i've been running to your help for like 3-4 years now. I really like your style and your mindset for helping idiots like me. :D

Link to comment
Share on other sites

Since 5 years member and only < 100 posts. Okeeeyyyyyy.

 

You have to use the transparency code again to display an ellipse.

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

;AutoIt version 3.3.8.0 or higher needed! Please update!

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172, $iTransCol = 0x555555
Global $iW = 400, $iH = 210
Global Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)

_WinAPI_SetLayeredWindowAttributes($hGUI, $iTransCol, 0xFF)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 20
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Global $iPerc

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

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, StringFormat("%05.2f %", $iPerc), 1, 0xFF000000 + $iTransCol)
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $iPerc += 0.1
    If $iPerc > 99.9 Then $iPerc = 0
EndFunc   ;==>PlayAnim

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $bHBitmap = True, $bBgTransCol = 0xFF010101, $iEllipseColor = 0xFF505050)
    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 $hBrushBg = _GDIPlus_BrushCreateSolid($iEllipseColor)
    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_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsClear($hCtxt, $bBgTransCol)
    _GDIPlus_GraphicsFillEllipse($hCtxt, ($iW - $iH) / 2, 0, $iH, $iH, $hBrushBG)

    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
    Local Static $iAngle = 0
    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_BrushDispose($hBrushBg)
    _GDIPlus_PenDispose($hPen)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_RotatingBokeh

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
            "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak

http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473%28v=vs.85%29.aspx

HRESULT DispCallFunc(
  void *pvInstance,
  ULONG_PTR oVft,
  CALLCONV cc,
  VARTYPE vtReturn,
  UINT cActuals,
  VARTYPE *prgvt,
  VARIANTARG **prgpvarg,
  VARIANT *pvargResult
);



http://msdn.microsoft.com/en-us/library/windows/desktop/ms221127%28v=vs.85%29.aspx
DWORD an unsigned 32 bit integer
typedef unsigned short VARTYPE;

oVft
DWORD an unsigned 32 bit integer
ULONG_PTR an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.

صرح السماء كان هنا

 

Link to comment
Share on other sites

Thanks for your reply wolf9228 but I don't understand what you want to say.

Are the types not correct?

Do I've to use it this way?

DllCall("oleaut32.dll", "long", "DispCallFunc", _
            "ptr", $hStream, _                  ;void *pvInstance (An instance of the interface described by this type description.),
            "ulong_ptr", 8 + 8 * @AutoItX64, _  ;ULONG_PTR oVft (For FUNC_VIRTUAL functions, specifies the offset in the VTBL.),
            "uint", 4, _                        ;CALLCONV cc (The calling convention. One of the CALLCONV values, such as CC_STDCALL.),
            "ushort", 23, _                     ;VARTYPE vtReturn (The variant type of the function return value. Use VT_EMPTY to represent void.),
            "uint", 0, _                        ;UINT cActuals (The number of function parameters.),
            "ptr", 0, _                         ;VARTYPE *prgvt (An array of variant types of the function parameters.),
            "ptr*", 0, _                        ;VARIANTARG **prgpvarg (The function parameters.),
            "ptr", DllStructGetPtr($tVARIANT))  ;VARIANT *pvargResult (The function result.)

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Since 5 years member and only < 100 posts. Okeeeyyyyyy.

 

You have to use the transparency code again to display an ellipse.

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

;AutoIt version 3.3.8.0 or higher needed! Please update!

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172, $iTransCol = 0x555555
Global $iW = 400, $iH = 210
Global Const $hGUI = GUICreate("Rotating Bokeh", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)

_WinAPI_SetLayeredWindowAttributes($hGUI, $iTransCol, 0xFF)
GUISetState()
Global $hHBmp_BG, $hB, $iSleep = 20
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

Global $iPerc

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

Func PlayAnim()
    $hHBmp_BG = _GDIPlus_RotatingBokeh($iW, $iH, StringFormat("%05.2f %", $iPerc), 1, 0xFF000000 + $iTransCol)
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    $iPerc += 0.1
    If $iPerc > 99.9 Then $iPerc = 0
EndFunc   ;==>PlayAnim

Func _GDIPlus_RotatingBokeh($iW, $iH, $sString = "Please wait...", $bHBitmap = True, $bBgTransCol = 0xFF010101, $iEllipseColor = 0xFF505050)
    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 $hBrushBg = _GDIPlus_BrushCreateSolid($iEllipseColor)
    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_GraphicsSetSmoothingMode($hCtxt, 2)
    _GDIPlus_GraphicsClear($hCtxt, $bBgTransCol)
    _GDIPlus_GraphicsFillEllipse($hCtxt, ($iW - $iH) / 2, 0, $iH, $iH, $hBrushBG)

    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
    Local Static $iAngle = 0
    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_BrushDispose($hBrushBg)
    _GDIPlus_PenDispose($hPen)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_RotatingBokeh

Br,

UEZ

This works like a charm.

I don't use autoit as a day to day tool. I refer to it time to time. So thats why i have pretty low post count. Also i don't know lots of programming routines so i couldn't help others actually :(

Anyways, thank you sir. Even though i couldn't use this loading screen on my final script, i owe you, i believe lots of us do. 

If you ever come to Turkey (ankara) i will buy you a beer ;)

Link to comment
Share on other sites

What will Tayyip (Zübük) Erdogan say when we drink alcohol?  :D

Btw, where are you exactly in Ankara? A lot of my relatives are living in Ankara..  :whisper:

Slm,

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 3 weeks later...

Added some more examples and more will follow...  :rolleyes:

Just look to the 1st post for screenshots and download link.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

×
×
  • Create New...