11月282017
圆形进度条
```#include <WindowsConstants.au3>
; #include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <StaticConstants.au3>
Global $hDC, $hPen_Background, $hPen_Progress, $obj_orig
Global Const $_color_Background = 0xf0f000 ; 画线进度条的底色
Global Const $_color_Progress = 0x0000ff ; 画线进度条的前景色
Global Const $start_x = 150 ; 圆心x
Global Const $start_y = 80 + 25 ; 圆心y y坐标需要加 25
Global Const $length = 50 ; 半径
Global Const $width = 6 ; 宽度
Global Const $Label1_l = 60 ; $Label1 的宽度
Global Const $Label1_h = 17 ; $Label1 的高度
Global Const $Label1_x = $start_x - Int($Label1_l / 2) - 2 ; $Label1 的位置x
Global Const $Label1_y = $start_y - 15 ; $Label1 的位置y
$Form1 = GUICreate('Form1', 300, 200, -1, 100)
$button1 = GUICtrlCreateButton("开始", 20, 150, 130, 30)
$Label1 = GUICtrlCreateLabel("0/0", $Label1_x, $Label1_y, $Label1_l, $Label1_h, $SS_CENTER)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
_Main()
EndSwitch
WEnd
Func _Main()
_LineProgress_prep() ; 准备
Local $i_num = 88 ; 总个数
Local $i_progress
For $i = 1 To $i_num
; 代码
Sleep(50)
$i_progress = Int($i / $i_num * 360)
_LineProgress_draw($i_progress) ;画进度线
GUICtrlSetData($Label1, $i & "/" & $i_num)
Next
MsgBox(0, 0, "完成")
_LineProgress_clean() ; 清除画线
EndFunc ;==>_Main
Func _LineProgress_prep() ; 准备
$hDC = _WinAPI_GetWindowDC($Form1) ; 场景
$hPen_Background = _WinAPI_CreatePen($PS_SOLID, $width, $_color_Background)
$hPen_Progress = _WinAPI_CreatePen($PS_SOLID, $width, $_color_Progress)
$obj_orig = _WinAPI_SelectObject($hDC, $hPen_Background) ; 使用画底色的笔。
_WinAPI_MoveTo($hDC, $start_x, $start_y)
_WinAPI_AngleArc($hDC, $start_x, $start_y, $length, 90, -360) ; 如果不要底色圆,可以屏蔽此行#######
$obj_orig = _WinAPI_SelectObject($hDC, $hPen_Progress) ; 使用画前景色的笔
EndFunc ;==>_LineProgress_prep
Func _LineProgress_draw($_progress) ;画进度线
;~ $_progress 范围: 0-360
_WinAPI_MoveTo($hDC, $start_x, $start_y)
_WinAPI_AngleArc($hDC, $start_x, $start_y, $length, 90, -$_progress)
EndFunc ;==>_LineProgress_draw
Func _LineProgress_clean() ; 清除资源
; 清除画线
_WinAPI_RedrawWindow($Form1)
; 清除资源
_WinAPI_SelectObject($hDC, $obj_orig)
_WinAPI_DeleteObject($hPen_Background)
_WinAPI_DeleteObject($hPen_Progress)
_WinAPI_ReleaseDC(0, $hDC)
EndFunc ;==>_LineProgress_clean```
```
扫描二维码,在手机上阅读
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!
有没有效果图