Sign in to follow this  
Followers 0
Catalyst159

Incorporate an image with my progress bar

1 post in this topic

I am trying to insert an image in the circle of the progress bar, so that the progress bar progresses around the image. I am not sure how to go about accomplishing this. Would I use _GDIPlus_ImageLoadFromFile, maybe use the image as a fill for the circle? Any help would be greatly appreciated. The code I have so far is as follows:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)

Global $h = 100
Global $w = $h, $pen_size, $font, $fsize, $hPen, $hGraphics, $hBitmap, $hBackbuffer, $hGUI

_CircleDisplay()
_GUI1()

While 1
    Sleep(100)
WEnd

Func _GUI1()
    GUICreate("HP WIZARD DUELS - DECK GENERATOR R1.V1", -1, -1, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState(@SW_SHOW)
EndFunc ;==>_GUI1

Func _CircleDisplay()
    $hGUI = GUICreate("Loading", $w, $h, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
    GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
    Local $bg_color = 0xFFFFFF
    Local $fx, $progress
    Local $angle = 0
    Local $size = 50
    Local $current = 0
    GUISetBkColor($bg_color)
    _WinAPI_SetLayeredWindowAttributes($hGUI, $bg_color, 0xFF)
    GUISetState()
    Circle_Progress_Init($hGUI, $w, $h, $bg_color)
    Do
        $progress = $current / $size
        $angle = $progress * 360
        Circle_Progress($angle, $progress * 100)
        $current += 1
        Sleep(50)
    Until $angle > 359
    Sleep(500)
    Circle_Progress(360, "DONE", "%s")
    Circle_Progress_Close()
    GUIDelete()
EndFunc

Func Circle_Progress_Init($hWnd, $Weight, $Height, $bg_color = 0xFFFFFF)
    _GDIPlus_Startup()
    $font = "Times New Roman"
    $fsize = Floor($h / 10)
    $pen_size = Floor($Height / 6)
    $hPen = _GDIPlus_PenCreate(0, $pen_size)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Weight, $Height, $hGraphics)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
EndFunc

Func Circle_Progress($angle, $text, $sFormat = "%.2f", $fg_pencolor = 0xFF0000FF, $bg_pencolor = 0xFFD0FFD0, $clear_color = 0xFFFFFFFF)
    Local $ps2 = $pen_size / 2
    _GDIPlus_GraphicsClear($hBackbuffer, $clear_color)
    _GDIPlus_PenSetColor($hPen, $bg_pencolor)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, $hPen)
    _GDIPlus_PenSetColor($hPen, $fg_pencolor)
    _GDIPlus_GraphicsDrawArc($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, -90, $angle, $hPen)
    Local $fx = StringLen(StringFormat($sFormat, $text)) * $fsize / 2.5
    _GDIPlus_GraphicsDrawString($hBackbuffer, StringFormat($sFormat, $text), $w / 2 - $fx, $h / 2 - $fsize * 0.75, $font, $fsize)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $w, $h)
EndFunc

Func Circle_Progress_Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc

Func _Exit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0