绿色风's Blog
专注AutoIT(Au3)
  • 首页
  • 流●年
  • 笔●记
    • 学习随记
    • 源码示例
  • 脚●本
    • UDF(收集)
    • 工作室UDF
    • 工具●教程
    • 教程之GDI
  • 作●品
  • 下●载
  • 情怀ExcelTip
11月282017

圆形进度条

作者:eaglelin   发布:2017-11-28 0:22 Tuesday   分类:学习随记   阅读:14065次   评论:1条  
```#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```

```



本文固定链接: http://www.jianyiit.com/post-279.html

blogger
该日志由 eaglelin 于2017-11-28 0:22 Tuesday发表在 学习随记 分类下。
版权所有:《绿色风's Blog》 → 《圆形进度条》;
除特别标注,本博客很多文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:

扫描二维码,在手机上阅读
上一篇::两行互换
下一篇:在窗口显示FLASH

热门文章

相关文章

  • [推荐]控件的各事件的绑定
  • ListView 单元格实时编辑
  • 获取图片尺寸
  • 获取磁盘信息
  • Dictionary对象的操作
评论列表 ↓
呦,果断人中龙凤! qw      2018-04-23 17:36 @回复
有没有效果图
取消回复

发表评论

亲,头像对么?

48 + 24 =

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


    站点统计
    • 运行时间: 20254 天
    • 日志总数: 365 篇
    • 评论数量: 7237 条
    • 微语数量: 6 条
    • 附件总量: 388 件
  • 逝出的青春

  • 打赏"绿色风"



      扫码关注本站公众号 可搜本站内容

  • Autoit V3 脚本交流群

      常驻群1:905774875
      常驻群2:40672266


  • 链接

    • AU3中文论坛
    • Excel资料库
    • 完美者博客
    • 顺网小哥'S Blog
    • 猛牛哥的博客
    • 网吧系统下载
  • 分类

    • 流●年(66)
    • 笔●记(0)
    • 脚●本(0)
    • 作品(21)
    • 学习随记(51)
    • 源码示例(68)
    • UDF(收集)(26)
    • 工作室UDF(30)
    • 工具●教程(62)
    • 教程之GDI(24)
Copyright © 2013 绿色风's Blog. Powered by emlog. Theme by 射雕天龙. 鄂ICP备2021011689号-1 鄂公网安备42102302000078号 sitemap