博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VBA api创建进度条
阅读量:6312 次
发布时间:2019-06-22

本文共 1362 字,大约阅读时间需要 4 分钟。

Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwE As Long, ByVal lpC As String, ByVal lpW As String, ByVal dwS As Long, ByVal x As Long, ByVal y As Long, ByVal nW As Long, ByVal nH As Long, ByVal hW As Long, ByVal hM As Long, ByVal hI As Long, lpP As Any) As Long

Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const PBM_SETPOS = &H402
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wP As Long, lP As Any) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMs As Long)
Private Const WM_SETTEXT = &HC
Dim hwndPro As Long
Private Declare Sub InitCommonControls Lib "comctl32" ()
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub UserForm_Click()
Dim hwnd&
hwnd = FindWindow("ThunderDFrame", Me.Caption) '获取窗口句柄
    Dim i As Integer
    hwndPro = CreateWindowEx(0, "msctls_progress32", "", WS_VISIBLE Or WS_CHILD, 10, 10, 200, 20, hwnd, 0&, Application.Hinstance, 0&)
    For i = 0 To 100
        Sleep 20: DoEvents
        SendMessage hwndPro, PBM_SETPOS, i, 0
        SendMessage hwnd, WM_SETTEXT, 0, ByVal CStr(i & "%")
    Next
End Sub
Private Sub UserForm_Initialize()
 InitCommonControls
End Sub

转载于:https://www.cnblogs.com/yuzhengdong/p/3707770.html

你可能感兴趣的文章
我的Android进阶之旅------>WindowManager.LayoutParams介绍
查看>>
segment
查看>>
获取鼠标的原始移动值
查看>>
Linux信号 编程
查看>>
有关滚动与位置
查看>>
Box2D自定义重力
查看>>
chpasswd
查看>>
mysqldump --single-transaction 和--lock-tables参数详解
查看>>
android 数据库_sql语句总结
查看>>
python购物车
查看>>
解决python2和python3的pip冲突
查看>>
面试/编程
查看>>
linux每日命令(16):head命令
查看>>
公司内部分享【富有成效的每日站会】总结
查看>>
打造一个上传图片到图床利器的插件(Mac版 开源)
查看>>
iOS横竖屏
查看>>
thinkphp判断更新是否成功
查看>>
Do While ... Loop 与 Do Until ... Loop 的区别
查看>>
【Linux】查询某个字符串出现次数
查看>>
高效使用jquery之一:请使用'On'函数
查看>>