October 21, 2018
Hot Topics:

Create a Progress Bar using the API

  • November 20, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

Add a new module (modProgBar) and copy the following code into it:

Option Explicit 
'// Windows API Declares  
Public Declare Function CreateWindowEX Lib_
    "user32" _ 
    Alias "CreateWindowExA"_
    (ByVal dwExStyle As Long, _ 
    ByVal lpClassName As String, _ 
    ByVal lpWindowName As String, _ 
    ByVal dwStyle As Long, _ 
    ByVal x As Long, _ 
    ByVal y As Long, _ 
    ByVal nWidth As Long, _ 
    ByVal nHeight As Long, _ 
    ByVal hWndParent As Long, _ 
    ByVal hMenu As Long, _ 
    ByVal hInstance As Long, lpParam As Any)_
    As Long 
Public Declare Function DestroyWindow Lib_
    "user32" _ 
    (ByVal hwnd As Long) As Long 
Public Declare Function MoveWindow Lib "_
    user32" _ 
    (ByVal hwnd As Long, ByVal x As Long, _ 
    ByVal y As Long, ByVal nWidth As Long, _ 
    ByVal nHeight As Long, ByVal bRepaint As Long)_
    As Long 
Public Declare Function SetParent Lib_
    "user32" _ 
    (ByVal hWndChild As Long, _ 
    ByVal hWndNewParent As Long) As Long 
Public Declare Function SendMessage Lib_
    "user32" _ 
    Alias "SendMessageA"_
    (ByVal hwnd As Long, _ 
    ByVal wMsg As Long, ByVal wParam_
    As Long, lParam As Any) As Long 
 '// Progess bar class name  
Public Const PROGRESS_CLASS =_
 '// Windows Messages and styles  
Public Const WM_USER = &H400 
Public Const WS_VISIBLE = &H10000000 
Public Const WS_CHILD = &H40000000 
 '// Progress bar styles and messages  
Public Const PBS_SMOOTH = &H1 
Public Const PBS_VERTICAL = &H4 
Public Const PBM_SETRANGE = (WM_USER + 1) 
Public Const PBM_SETPOS = (WM_USER + 2) 
Public Const PBM_DELTAPOS = (WM_USER + 3) 
Public Const PBM_SETSTEP = (WM_USER + 4) 
Public Const PBM_STEPIT = (WM_USER + 5) 
Public Const PBM_SETRANGE32 = (WM_USER + 6) 
Public Const PBM_GETRANGE = (WM_USER + 7) 
Public Const PBM_GETPOS = (WM_USER + 8) 
Public Const PBM_SETBARCOLOR = (WM_USER + 9) 
 '// Common Controls messages  
Public Const CCM_FIRST = &H2000 
Public Const CCM_SETBKCOLOR = (CCM_FIRST + 1) 

Page 2 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date