Jump to content

Trying to download files with progress


Recommended Posts

Hello all, I am trying to use inetget() to download a series of files one at a time, however my script stops at 0/38 pieces and the progress bar goes to 100%.

 

Can someone please point out what I'm doing wrong in this script?

 

;AutoIt v3.3.9.21 or higher needed!
;coded by UEZ build 2013-08-15
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <Inet.au3>
#include <File.au3>
#include "_GDIPlus_StripProgressbar.au3"

If FileGetVersion(@AutoItExe) < "3.3.09.21" Then Exit MsgBox(16, "Error", "AutoIt version 3.3.9.18 or higher needed!", 30)
InetGet("http://intranet.pdglobal.net/images/verselogo.jpg", @tempdir&"\verselogo.jpg")

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF
Global Const $hGUI = GUICreate("The Verse Loader", 400, 275, -1, -1, Default, $WS_EX_TOPMOST)
GUISetBkColor(0xFFFFFF)
Global Const $iPic = GUICtrlCreatePic("", 0, 250, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreatePic(@tempdir&"\verselogo.jpg",0,0,400,250)
GUISetState()
Global $hB, $iSleep = 30
Global $fPerc, $fPercPrev, $iLoop, $aPos, $iPosX, $iPosY
Global $aColors[7][2] = [[0xFF00005B, 0xFFAAAAAA],[0xFF0000FF, 0xFFAAAAAA],[0xFF0000EE, 0xFFAAAAAA],[0xFF000058, 0xFFAAAAAA],[0xFF000077, 0xFFAAAAAA],[0xFF0000EE, 0xFFAAAAAA],[0xFF0000EE, 0xFFAAAAAA]]
Global $iRandom, $iColorTP, $hTooltip

Global $aTooltip = _Init(70, 50)
$blocks = StringTrimLeft(_INetGetSource("http://pdglobal.net/?sid=mcblocks"),1)
for $i=0 to Number($blocks)
    ConsoleWrite($i&"/"&$blocks&@CRLF)
    if StringLen($i) = 1 Then
        if not FileExists(@tempdir&"\MultiMC.7z.00"&$i) Then
            $hdownload = InetGet("http://prodynamics.tk/verse/MultiMC.7z.00"&$i, @tempdir&"\MultiMC.7z.00"&$i,1,1)
            $size = InetGetSize ("http://prodynamics.tk/verse/MultiMC.7z.00"&$i)
            Do
                Sleep(50)
                PlayAnim((InetGetInfo($hDownload, $INET_DOWNLOADREAD)/$size)*100, "Downloading MultiMC.7z.00"&$i&"...")
            Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

            PlayAnim(($i/$blocks)*100, "Downloading Files...")
        EndIf
    Else
        if not FileExists(@tempdir&"\MultiMC.7z.0"&$i) Then
            $hdownload = InetGet("http://prodynamics.tk/verse/MultiMC.7z.0"&$i, @tempdir&"\MultiMC.7z.0"&$i,1,1)
            $size = InetGetSize ("http://prodynamics.tk/verse/MultiMC.7z.0"&$i)
            Do
                Sleep(50)
                PlayAnim((InetGetInfo($hDownload, $INET_DOWNLOADREAD)/$size)*100, "Downloading MultiMC.7z.0"&$i&"...")
            Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

            PlayAnim(($i/$blocks)*100, "Downloading Files...")
        EndIf
    EndIf
Next
InetGet("http://prodynamics.tk/verse/7z.exe", @tempdir&"\7z.exe")
InetGet("http://prodynamics.tk/verse/7z.dll", @tempdir&"\7z.dll")
InetGet("http://prodynamics.tk/verse/7-zip.dll", @tempdir&"\7-zip.dll")
InetGet("http://prodynamics.tk/verse/7-zip32.dll", @tempdir&"\7-zip32.dll")

PlayAnim(100, "Done...")
if FileExists(@TempDir&"\MultiMC\MultiMC.exe") Then
    $version = FileRead(@TempDir&"\MultiMC\version.db")
    $srvversion = StringTrimLeft(_INetGetSource("http://pdglobal.net/?sid=mcversion"),1)
    if $srvversion > $version Then
        $files = _FileListToArray(@TempDir, '*', 0, true)
        for $i=0 to $files[0]
                FileDelete($files[$i])
        Next
        $files = _FileListToArray(@TempDir&"\MultiMC", '*', 0, true)
        for $i=0 to $files[0]
                FileDelete($files[$i])
        Next
        ShellExecute(@ScriptFullPath)
        Exit
    Else
        InetGet("http://prodynamics.tk/verse/7z.exe", @tempdir&"\7z.exe")
InetGet("http://prodynamics.tk/verse/7z.dll", @tempdir&"\7z.dll")
InetGet("http://prodynamics.tk/verse/7-zip.dll", @tempdir&"\7-zip.dll")
InetGet("http://prodynamics.tk/verse/7-zip32.dll", @tempdir&"\7-zip32.dll")
FileWrite(@TempDir&"\MultiMC\version.db", $srvversion)
    $term = Run(@tempdir&"\7z.exe x "&@tempdir&"\MultiMC.7z.001", @tempdir, @SW_HIDE, 0x1)
$percent = 0
$timer = TimerInit()
    EndIf

while ProcessExists($term)
    FileWrite("log.txt", ConsoleRead())
    if TimerDiff($timer) > 1000 Then
    $percent += 0.5
        PlayAnim($percent, "Unpacking Files...")
        $timer = TimerInit()
    EndIf
WEnd
PlayAnim(100, "Done...")
    EndIf

$term = Run(@tempdir&"\7z.exe x "&@tempdir&"\MultiMC.7z.001", @tempdir, @SW_HIDE, 0x1)
$percent = 0
$timer = TimerInit()
while ProcessExists($term)
    FileWrite("log.txt", ConsoleRead())
    if TimerDiff($timer) > 1000 Then
    $percent += 0.5
        PlayAnim($percent, "Unpacking Files...")
        $timer = TimerInit()
    EndIf
WEnd
PlayAnim(100, "Done...")

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_TIMER, "")
            _GDIPlus_Shutdown()
            Exit
;~          $fPerc = 0
;~          $iRandom = Random(0, UBound($aColors) - 1, 1)
;~          $iColorTP = $aColors[$iRandom][1]
;~          _WinAPI_SetLayeredWindowAttributes($aTooltip[0], $aTooltip[6], 255)
;~          GUIRegisterMsg($WM_TIMER, "PlayAnim")
;~          DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
    EndSwitch
Until False

Func _Init($iWidth = 70, $iHeight = 50, $iBGTColor = 0x0000BA)
    $hHBmp_BG = _GDIPlus_StripProgressbar(0, $iW, $iH, 0xFF0000FF + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], "")
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    Local $hGUI_ToolTip = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP + $WS_DISABLED, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $hGUI)
    GUISetBkColor($iBGTColor, $hGUI_ToolTip) ;set GUI background color
    Local $iPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
    GUISetState(@SW_HIDE, $hGUI_ToolTip)
    _WinAPI_SetLayeredWindowAttributes($hGUI_ToolTip, $iBGTColor, 0xFF)
    Local $aResult[7] = [$hGUI_ToolTip, $iPic, $iWidth, $iHeight, _WinAPI_GetSystemMetrics(7), _WinAPI_GetSystemMetrics(4) + _WinAPI_GetSystemMetrics(33), $iBGTColor]
    Return $aResult
EndFunc   ;==>_Init

Func PlayAnim($percent, $text)
    Local $sText = $text, $i, $iCalc1, $iCalc2, $hHBmp_TP
    $fPerc = $percent
    If $fPerc >= 100 Then
        GUIRegisterMsg($WM_TIMER, "")
        $sText = "Done"
    EndIf
    $iLoop = $fPerc - $fPercPrev
    $fPercPrev = $fPerc

    For $i = $iLoop To 0 Step - 1
        $iCalc1 = ($fPerc - $i)
        $hHBmp_BG = _GDIPlus_StripProgressbar($iCalc1, $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)
        $aPosCtrl = ControlGetPos($hGUI, 0, $iPic)
        $aPosGUI = WinGetPos($hGUI)
        $iPosX = $aPosCtrl[0] + $aPosGUI[0] + $aTooltip[4] - $aTooltip[2] / 2
        $iPosY = $aPosCtrl[1] + $aPosGUI[1] - $aPosCtrl[3] - 2
        If $iCalc1 >= 100.5 Then $iCalc1 = 100
        $iCalc2 = $iPosX + ($fPerc - $i) / 100 * $iW - 1
        If $iCalc2 >= $iPosX + $iW Then $iCalc2 = $iPosX + $iW
        $hHBmp_TP = _GDIPlus_CreateToolTipBitmap(StringFormat("%02d%", $iCalc1), $aTooltip[2], $aTooltip[3])
        _WinAPI_DeleteObject(GUICtrlSendMsg($aTooltip[1], $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_TP))
        _WinAPI_DeleteObject($hHBmp_TP)
        If WinGetState($aTooltip[0]) <> 3 Then WinSetState($aTooltip[0], "", @SW_SHOWNA)
        WinMove($aTooltip[0], "", $iCalc2, $iPosY)
    Next
    If $fPerc >= 100.5 Then
        For $i = 255 To 0 Step - 4
            _WinAPI_SetLayeredWindowAttributes($aTooltip[0], $aTooltip[6], $i)
            Sleep(10)
        Next
        WinSetState($aTooltip[0], "", @SW_HIDE)
    EndIf
EndFunc   ;==>PlayAnim

Func _GDIPlus_CreateToolTipBitmap($sText, $iW = 70, $iH = 50, $sFont = "Times", $fFontSize = 11, $iBGColor = 0xFFFFFFFF, $iFontColor = 0xFF000000, $iRadius = 8, $hImage = 0, $iImgPosX = 8, $iImgPosY = 4, $iImgW = 16, $iImgH = 16, $bGDIBmp = 1)
    Local $iX = 0, $iY = 0, $iPenSize = 1, $iSize = 12, $iSize2 = $iSize / 2,   $iDX = $iW / 2
    Local $iWidth = $iW - $iPenSize, $iHeight = $iH - $iPenSize - $iSize
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90)
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
    _GDIPlus_PathAddLine($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight, $iDX + $iSize2, $iY + $iHeight)
    _GDIPlus_PathAddLine($hPath, $iDX + $iSize2, $iY + $iHeight, $iX + $iDX, $iY + $iHeight + $iSize)
    _GDIPlus_PathAddLine($hPath, $iX + $iDX, $iY + $iHeight + $iSize, $iX + $iDX - $iSize2, $iY + $iHeight)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90)
    _GDIPlus_PathCloseFigure($hPath)

    Local $hBrush = _GDIPlus_BrushCreateSolid($iBGColor)
    _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush)
    Local $hPen = _GDIPlus_PenCreate(0xFF000000, $iPenSize)
    _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen)

    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $aMeasure = _GDIPlus_GraphicsMeasureString($hCtxt, $sText, $hFont, $tLayout, $hFormat)
    DllStructSetData($tLayout, "Y", ($iHeight - DllStructGetData($aMeasure[0], "Height")) / 2)
    _GDIPlus_BrushSetSolidColor($hBrush, $iFontColor)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush)

    If $hImage Then
        _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
        _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hImage, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $iImgPosX, $iImgPosY, $iImgW, $iImgH)
    EndIf

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hCtxt)
    If $bGDIBmp Then
        Local $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hGDIBmp
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_CreateToolTipBitmap

 

Link to comment
Share on other sites

I don't have experience with your  GDI+ progress bar but if everything else turns out to be working fine, you might want to give the built in autoit Progress Bar a shot to see if it works that way. It might be a little less complicated, and then if you get that working it should be easier to switch over to your GDI+ version.

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Link to comment
Share on other sites

I've shorten your code a litte bit to show how it can be done:

;AutoIt v3.3.9.21 or higher needed!
;coded by UEZ build 2013-08-15
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <Inet.au3>
#include <File.au3>
#include <GDIPlus.au3>

If FileGetVersion(@AutoItExe) < "3.3.09.21" Then Exit MsgBox(16, "Error", "AutoIt version 3.3.9.18 or higher needed!", 30)
InetGet("http://intranet.pdglobal.net/images/verselogo.jpg", @TempDir & "\verselogo.jpg")


_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF
Global Const $hGUI = GUICreate("The Verse Loader", 400, 275, -1, -1, Default, $WS_EX_TOPMOST)
GUISetBkColor(0xFFFFFF)
Global Const $iPic = GUICtrlCreatePic("", 0, 250, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreatePic(@TempDir & "\verselogo.jpg", 0, 0, 400, 250)
GUISetState()

Global $fPerc, $fPercPrev, $iLoop, $aPos, $iPosX, $iPosY, $sText, $hdownload
Global $aColors[7][2] = [[0xFF00005B, 0xFFAAAAAA], [0xFF0000FF, 0xFFAAAAAA], [0xFF0000EE, 0xFFAAAAAA], [0xFF000058, 0xFFAAAAAA], [0xFF000077, 0xFFAAAAAA], [0xFF0000EE, 0xFFAAAAAA], [0xFF0000EE, 0xFFAAAAAA]]
Global $iRandom, $iColorTP, $hTooltip

Global $aTooltip = _Init(70, 50, $aColors[0][0], $aColors[0][1], 0xE0)
Global $blocks = StringTrimLeft(_INetGetSource("http://pdglobal.net/?sid=mcblocks"), 1)

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

For $iDLParts = 1 To Number($blocks)
    ConsoleWrite($iDLParts & "/" & $blocks & @CRLF)
    If StringLen($iDLParts) = 1 Then
        If Not FileExists(@TempDir & "\MultiMC.7z.00" & $iDLParts) Then
            $hdownload = InetGet("http://prodynamics.tk/verse/MultiMC.7z.00" & $iDLParts, @TempDir & "\MultiMC.7z.00" & $iDLParts, 1, 1)
            $size = InetGetSize("http://prodynamics.tk/verse/MultiMC.7z.00" & $iDLParts)
        EndIf
    Else
        If Not FileExists(@TempDir & "\MultiMC.7z.0" & $iDLParts) Then
            $hdownload = InetGet("http://prodynamics.tk/verse/MultiMC.7z.0" & $iDLParts, @TempDir & "\MultiMC.7z.0" & $iDLParts, 1, 1)
            $size = InetGetSize("http://prodynamics.tk/verse/MultiMC.7z.0" & $iDLParts)
        EndIf
    EndIf
    $sText = "Downloading " & $iDLParts & " / " & $blocks
    Do
        Sleep(100)
    Until InetGetInfo($hdownload, $INET_DOWNLOADCOMPLETE)
Next

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

Func _Init($iWidth, $iHeight, $iColor1, $iColor2, $iTransparency = 0xFF, $iBGTColor = 0xFEDCBA)
    Local $hHBmp_BG = _GDIPlus_StripProgressbar(0, $iW, $iH, 0xFF000000 + $iBGColor, $iColor1, $iColor2, "")
    Local $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
    Local $hGUI_ToolTip = GUICreate("", $iWidth, $iHeight, 0, 0, BitOR($WS_POPUP, $WS_DISABLED), BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $hGUI)
    GUISetBkColor($iBGTColor, $hGUI_ToolTip) ;set GUI background color
    Local $iPic_ProgressTP = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)
    GUISetState(@SW_HIDE, $hGUI_ToolTip)
    _WinAPI_SetLayeredWindowAttributes($hGUI_ToolTip, $iBGTColor, $iTransparency)
    Local $aResult[7] = [$hGUI_ToolTip, $iPic_ProgressTP, $iWidth, $iHeight, _WinAPI_GetSystemMetrics(7), _WinAPI_GetSystemMetrics(4) + _WinAPI_GetSystemMetrics(33), $iBGTColor]
    Return $aResult
EndFunc   ;==>_Init

Func PlayAnim()
    Local $i, $iCalc2, $hHBmp_TP
    Local $fPerc = $iDLParts / $blocks * 100
    Local $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)
    $aPosCtrl = ControlGetPos($hGUI, 0, $iPic)
    $aPosGUI = WinGetPos($hGUI)
    $iPosX = $aPosCtrl[0] + $aPosGUI[0] + $aTooltip[4] - $aTooltip[2] / 2
    $iPosY = $aPosCtrl[1] + $aPosGUI[1] - $aPosCtrl[3] - 2
    If $fPerc >= 100 Then $fPerc = 100
    $iCalc2 = $iPosX + $iDLParts / $blocks * $iW - 1
    If $iCalc2 >= $iPosX + $iW Then $iCalc2 = $iPosX + $iW
    $hHBmp_TP = _GDIPlus_CreateToolTipBitmap(StringFormat("%02d%", $fPerc), $aTooltip[2], $aTooltip[3])
    _WinAPI_DeleteObject(GUICtrlSendMsg($aTooltip[1], $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_TP))
    _WinAPI_DeleteObject($hHBmp_TP)
    If WinGetState($aTooltip[0]) <> 3 Then WinSetState($aTooltip[0], "", @SW_SHOWNA)
    WinMove($aTooltip[0], "", $iCalc2, $iPosY)

    If $fPerc >= 100 Then
        For $i = 255 To 0 Step -4
            _WinAPI_SetLayeredWindowAttributes($aTooltip[0], $aTooltip[6], $i)
            Sleep(10)
        Next
        WinSetState($aTooltip[0], "", @SW_HIDE)
        GUIRegisterMsg($WM_TIMER, "")
    EndIf
EndFunc   ;==>PlayAnim

Func _GDIPlus_CreateToolTipBitmap($sText, $iW = 70, $iH = 50, $sFont = "Times", $fFontSize = 11, $iBGColor = 0xFFFFFFFF, $iFontColor = 0xFF000000, $iRadius = 8, $hImage = 0, $iImgPosX = 8, $iImgPosY = 4, $iImgW = 16, $iImgH = 16, $bGDIBmp = 1)
    Local $iX = 0, $iY = 0, $iPenSize = 1, $iSize = 12, $iSize2 = $iSize / 2, $iDX = $iW / 2
    Local $iWidth = $iW - $iPenSize, $iHeight = $iH - $iPenSize - $iSize
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90)
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
    _GDIPlus_PathAddLine($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight, $iDX + $iSize2, $iY + $iHeight)
    _GDIPlus_PathAddLine($hPath, $iDX + $iSize2, $iY + $iHeight, $iX + $iDX, $iY + $iHeight + $iSize)
    _GDIPlus_PathAddLine($hPath, $iX + $iDX, $iY + $iHeight + $iSize, $iX + $iDX - $iSize2, $iY + $iHeight)
    _GDIPlus_PathAddArc($hPath, $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90)
    _GDIPlus_PathAddArc($hPath, $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90)
    _GDIPlus_PathCloseFigure($hPath)

    Local $hBrush = _GDIPlus_BrushCreateSolid($iBGColor)
    _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush)
    Local $hPen = _GDIPlus_PenCreate(0xFF000000, $iPenSize)
    _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen)

    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $aMeasure = _GDIPlus_GraphicsMeasureString($hCtxt, $sText, $hFont, $tLayout, $hFormat)
    DllStructSetData($tLayout, "Y", ($iHeight - DllStructGetData($aMeasure[0], "Height")) / 2)
    _GDIPlus_BrushSetSolidColor($hBrush, $iFontColor)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush)

    If $hImage Then
        _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
        _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hImage, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $iImgPosX, $iImgPosY, $iImgW, $iImgH)
    EndIf

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hCtxt)
    If $bGDIBmp Then
        Local $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hGDIBmp
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_CreateToolTipBitmap

Func _GDIPlus_StripProgressbar($fPerc, $iW, $iH, $iBgColorGui = 0xFFF0F0F0, $iFgColor = 0xFFEE5F5B, $iBGColor = 0xFFF07673, $sText = "Loading...", $iTextColor = 0x000000, $iDir = -1, $iSpeed = 1, $sFont = "Arial", $bFlip = False, $bHBitmap = True)
    If $fPerc < 0 Then $fPerc = 0
    If $fPerc > 100 Then $fPerc = 100

    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hCtxt, $iBgColorGui)

    Local $iWidth = $iH * 2, $iLen = $iWidth / 2, $iY
    Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iWidth, $iH)
    Local Const $hCtxt_Bmp = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt_Bmp, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    Local $hPen = _GDIPlus_PenCreate($iFgColor), $iPenSize = Int($iH / 12)
    Local $hPen2 = _GDIPlus_PenCreate(0x50000000, $iPenSize)

    _GDIPlus_GraphicsClear($hCtxt_Bmp, $iBGColor)
    Local Static $iX = 0
    For $iY = 0 To $iH - 1
        Switch $iDir
            Case 1
                _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY, $iY, $iX + $iY + $iLen, $iY, $hPen)
                _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY - 2 * $iLen, $iY, $iX + $iY - 1 * $iLen, $iY, $hPen)
            Case Else
                _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY, $iY, -$iX + $iY + $iLen, $iY, $hPen)
                _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY + 2 * $iLen, $iY, -$iX + $iY + 3 * $iLen, $iY, $hPen)
        EndSwitch
    Next
    Local $tPoint1 = DllStructCreate("float;float")
    Local $tPoint2 = DllStructCreate("float;float")
    DllStructSetData($tPoint1, 1, $iW / 2) ;x1
    DllStructSetData($tPoint2, 1, $iW / 2) ;x2
    Local $hLineBrush

    If $bFlip Then
        _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, 0, $iWidth, 0, $hPen2)
        DllStructSetData($tPoint1, 2, $iH / 3) ;y1
        DllStructSetData($tPoint2, 2, $iH * 2 / 3) ;y2
        $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0x00FFFFFF, "uint", 0xB0FFFFFF, "int", 0, "int*", 0)
        $hLineBrush = $hLineBrush[6]
        _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, $iH * 2 / 3 + 1, $iW, $iH / 3, $hLineBrush)
    Else
        _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, $iH - $iPenSize / 2, $iWidth, $iH - $iPenSize / 2, $hPen2)
        DllStructSetData($tPoint1, 2, 0) ;y1
        DllStructSetData($tPoint2, 2, $iH / 3) ;y2
        $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0xB0FFFFFF, "uint", 0x00FFFFFF, "int", 0, "int*", 0)
        $hLineBrush = $hLineBrush[6]
        _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, 0, $iW, $iH / 3, $hLineBrush)
    EndIf
    $iX = Mod($iX + $iSpeed, $iWidth)

    Local $hTextureBrush = _GDIPlus_TextureCreate($hBmp)

    _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $fPerc / 100 * $iW, $iH, $hTextureBrush)
    If $bFlip Then _GDIPlus_ImageRotateFlip($hBitmap, 6)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 4)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0x40000000 + $iTextColor)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $iH * 3 / 5, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_GraphicsDispose($hCtxt_Bmp)
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_BrushDispose($hTextureBrush)
    _GDIPlus_BrushDispose($hLineBrush)
    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_StripProgressbar

 

Info: downloading all 38 files ~ 371 MB!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...