VBA API Create progress bar

Source: Internet
Author: User

Private Declare Function CreateWindowEx Lib "user32" Alias "Createwindowexa" (ByVal DwE as Long, ByVal LpC as String, Byva L 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 A s 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 S Tring) as Long

Private Sub Userform_click ()
Dim hwnd&
hwnd = FindWindow ("Thunderdframe", me.caption) ' Get window handle
Dim I as Integer
Hwndpro = CreateWindowEx (0, "Msctls_progress32", "" "," ws_visible "Or" Ws_child "," Ten "," Max "), hwnd, 0&, Application.hi Nstance, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.