#include
#include
#include
#include
#include
#include
#include
Global $ahCallBack[2], $iPrecent
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 344, 81, 533, 227)
$Button1 = GUICtrlCreateButton("Button1", 24, 8, 75, 25)
$Label1 = GUICtrlCreateLabel(" ", 16, 40, 290, 10)
GUICtrlSetBkColor(-1, 0xA0A0A0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GDIPlus_Startup()
$hGraphic1 = _GDIPlus_GraphicsCreateFromHWND($Form1)
$hBitMap = _GDIPlus_BitmapCreateFromGraphics(344, 9, $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitMap)
$hPen = _GDIPlus_PenCreate(0,1)
$Depth = 1.70 ; Min = 1.10 Max = 1.70
For $i = 1 To 20
$PenColor = "0xFF" & Hex(80 + $i, 2) & Hex(Round(240 - $i^$Depth), 4) & "3B" ; Green
_GDIPlus_PenSetColor($hPen, $PenColor)
_GDIPlus_GraphicsDrawLine($hGraphic2, 9, $i-1, 460, $i-1, $hPen)
Next
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic2)
$hBitMap_Multiply = _GDIPlus_BitmapCreateFromGraphics(341, 9, $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitMap_Multiply)
_GDIPlus_GraphicsDispose($hGraphic2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If $iPrecent = 0 Then _WinAPI_RedrawWindow($Form1)
If GUICtrlRead($Button1) = "Stop" Then
GUICtrlSetData($Button1, "Start")
CallBack_Free($ahCallBack)
ContinueLoop
EndIf
GUICtrlSetData($Button1, "Stop")
$ahCallBack = CallBack_Init("Paint_Proc", 10)
EndSwitch
WEnd
Func Paint_Proc($hWnd, $nMsg, $wParam, $lParam)
$iPrecent += 1
;~ GUICtrlSetData($Status_Label, Round($iPrecent / 3) & "%")
If $iPrecent > 300 Then
$iPrecent = 0
;~ GUICtrlSetData($Status_Label, "100%")
GUICtrlSetData($Button1, "Start")
CallBack_Free($ahCallBack)
$ahCallBack = 0
Dim $ahCallBack[2] = [-1, -1]
EndIf
_GDIPlus_GraphicsDrawImageRectRect($hGraphic1, $hBitMap, 0, 0, $iPrecent, 19, 7, 40, $iPrecent, 20)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic1, $hBitMap_Multiply, 0, 0, $iPrecent, 20, 10, 40, $iPrecent, 20)
EndFunc
Func CallBack_Init($sFuncName, $iTime, $sParam = "hwnd;int;int;dword")
Local $hCallBack = DLLCallbackRegister($sFuncName, "int", $sParam)
Local $aTimer = DllCall("user32.dll", "uint", "SetTimer", _
"hwnd", 0, "uint", 0, "int", $iTime, "ptr", DllCallbackGetPtr($hCallBack))
Local $ahCallBack[2] = [$hCallBack, $aTimer[0]]
Return $ahCallBack
EndFunc
Func CallBack_Free($ahCallBack)
If $ahCallBack[0] <> -1 Then DllCallbackFree($ahCallBack[0])
If $ahCallBack[1] <> -1 Then DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $ahCallBack[1])
EndFunc