Jump to content

Recommended Posts

Posted

I found a very beautiful progress bar UDF, the source code is as follows

;Fast hack by UEZ ;-)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
;#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>


Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $h = 150, $w = $h

Global $hGUI = GUICreate("GDI+ Circle Progress Meter by UEZ 2010", $w, $h, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global $bg_color = 0xFFFFFF
GUISetBkColor($bg_color)
_WinAPI_SetLayeredWindowAttributes($hGUI, $bg_color, 0xFF)
GUISetState()

Circle_Progress_Init($hGUI, $w, $h, $bg_color)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

Global $fx, $progress
Global $angle = 0
Global $size = 111
Global $current = 0
Do
    $progress = $current / $size
    $angle = $progress * 360
    Circle_Progress($angle, $progress * 100)
    $current += 1
    Sleep(75)
Until $angle > 359

Sleep(500)
Circle_Progress(360, "Done", "%s")
Sleep(2500)
_Exit()

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

Func Circle_Progress($angle, $text, $sFormat  = "%.2f", $fg_pencolor = 0xFF00FF00, $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)
    $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 ;==>WM_NCHITTEST

Func _Exit()
    Circle_Progress_Close()
    GUIDelete($hGUI)
    Exit
EndFunc

When I ran it in online system mode, everything worked fine.But when I run it in WinRE mode on a WIN7 X64 system, percentages are not displayed. Can you guys help me? Thanks a lot!

sshot-1.png.8f56bd5becee41522e30810f248f7c15.png

Posted (edited)

When the online system, the background is transparent, but in WinRE mode, the background becomes white, can the progress bar background become transparent in WinRE mode?

@UEZI'm really looking forward to your help.

Edited by i2i8
Posted (edited)

Look here (maybe it will help you ...)

https://learn.microsoft.com/en-us/windows/win32/winmsg/using-windows

  Quote

In order to use layered child windows, the application has to declare itself Windows 8-aware in the manifest.

For windows 10/11, one can include this compatibility snippet in its app.manifest to make it Windows 10-aware :

Expand  

 

...
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- Windows 10 GUID -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
    </application>
</compatibility>
...

 

Edited by Zedna

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
  • Recently Browsing   0 members

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