Visual Basic Common Control API Routines
CreateWindowEx: Common Control ProgressBar API Overview
     
Posted:   Sunday June 29, 1997
Updated:   Monday December 26, 2011
     
Applies to:   VB4-32, VB5, VB6
Developed with:   VB4-32, Windows 95
OS restrictions:   None
Author:   Brad Martinez
     

Related:  

SetParent: Add a VB Progress Bar to a VB StatusBar
SendMessage: Change the Colour of a VB ProgressBar
Pure VB: Customizable PhotoShop-Style ProgressBar
Pure VB: Customizable PhotoShop-Style ProgressBar in a MDI App
CreateWindowEx: Creating the Common Control Flood Panel via the API
SetParent: Display Modal Form Activity on a Parent Form's 'PhotoShop-style' ProgressBar
SetParent: Display Modal Form Activity in a Parent Form's VB ProgressBar
     
 Overview
The following is an explanation of the messages and structures used by the Windows ProgressBarcommon control, written by Brad Martinez and provided for distribution on VBnet.

The Windows Common Controls API continues to grow as more features are added. Currently, comctl32.dll contains the following classes:

ICC_LISTVIEW_CLASSES ' listview, header
ICC_TREEVIEW_CLASSES ' treeview, tooltips
ICC_BAR_CLASSES ' toolbar, statusbar, trackbar, tooltips
ICC_TAB_CLASSES ' tab, tooltips
ICC_UPDOWN_CLASS ' updown
ICC_PROGRESS_CLASS ' progress
ICC_HOTKEY_CLASS ' hotkey
ICC_ANIMATE_CLASS ' animate
ICC_WIN95_CLASSES ' loads everything above
ICC_DATE_CLASSES ' month picker, date picker, time picker, updown
ICC_USEREX_CLASSES ' ComboEx
ICC_COOL_CLASSES ' Rebar (coolbar) control

Whenever an OCX-based component can be eliminated from a VB project, the resulting executable, and the files required for distribution are reduced. In addition, the code execution is often considerably faster, often with little overhead in code maintenance. This page, and its companion code page Creating the Common Control ProgressBarvia the API will detail how to create and use the Windows 95 ProgressBarcommon control in a Visual Basic application.

 BAS Module Code - The Common Control ProgressBar
Place the following code into the general declarations area of a bas module:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'ProgressBarMessages

Public Const WM_USER As Long = &H400

'The PBM_SETRANGE message sets the minimum and 
'maximum values for a progress bar and redraws 
'the bar to reflect the new range.
'  wParam = 0
'  lParam =nMinRange Or (nMaxRange * &H10000)
'
'  nMinRange = Minimum range value specified 
'      in the lParam low word.
'      Default value is zero.
'
'  nMaxRange = Maximum range value specified 
'      in the lParam high word.
'      Default value is 100.
'
'Returns the previous range values if successful, or zero otherwise. The
'low-order word specifies the previous minimum value, and the high-order
'word specifies the previous maximum value.  
Public Const PBM_SETRANGE As Long = (WM_USER + 1)


'The PBM_SETPOS message sets the current position 
'for a progress bar and redraws the bar to reflect 
'the new position.
'  wParam = New position.
'  lParam = 0
'
'Returns the previous position.  
Public Const PBM_SETPOS As Long = (WM_USER + 2)


'The PBM_DELTAPOS message advances the current position 
'of a progress bar by a specified increment and redraws 
'the bar to reflect the new position.
'  wParam = Amount to advance the position.
'  lParam = 0
'
'Returns the previous position.  
Public Const PBM_DELTAPOS As Long = (WM_USER + 3)


'The PBM_SETSTEP message specifies the step increment 
'for a progress bar. The step increment is the amount 
'by which the progress bar increases its current position 
'whenever it receives a PBM_STEPIT message. By default,
'the step increment is set to 10.
'  wParam = New step increment.
'  lParam = 0
'
'Returns the previous step increment.  
Public Const PBM_SETSTEP As Long = (WM_USER + 4)


'The PBM_STEPIT message advances the current position 
'for a progress bar by the step increment and redraws the 
'bar to reflect the new position. An application sets the 
'step increment by sending the PBM_SETSTEP message.
'  wParam = 0
'  lParam = 0
'
'Returns the previous position.
'When the position exceeds the maximum range value, this 
'message resets the current position so that the progress 
'indicator starts over again from the beginning.  
Public Const PBM_STEPIT As Long = (WM_USER + 5)
  
'====================================
'IE3 and later...

'The PBM_SETRANGE32 message sets the range of a progress bar 
'control to a 32-bit value.
'  wParam = A 32-bit value that represents the low limit to 
' be set for the progress bar control.
'  lParam = A 32-bit value that represents the high limit to 
' be set for the progress bar control.
'
'Returns a DWORD that holds the previous 16-bit low limit 
'in its low word, and the previous 16-bit high limit in its 
'high word. If the previous ranges were 32-bit values, the 
'return value consists of the low words of both 32-bit limits.
'To retrieve the entire high and low 32-bit values, use the 
'PBM_GETRANGE message.  
Public Const PBM_SETRANGE32 As Long = (WM_USER + 6)

  
'The PBM_GETRANGE message retrieves information about the 
'current high and low limits of a given progress bar control.
'  wParam = Flag value specifying which limit value is to be 
' used as the message's return value. This parameter 
' can be one of the following values:
' Value  Meaning
' TRUE   Return the low limit.
' FALSE Return the high limit.
'  lParam = Address of a PBRANGE structure that is to be filled 
'with the high and low limits of the progress bar control.
'If this parameter is set to NULL, the control will 
'return only the limit specified by wParam.
'
'Returns an INT that represents the limit value specified by wParam.
'If lParam is not NULL, lParam must point to a PBRANGE structure
'that is to be filled with both limit values.  
Public Const PBM_GETRANGE As Long = (WM_USER + 7)

Public Type PPBRANGE
  iLow  As Integer
  iHigh As Integer
End Type

  
'The PBM_GETPOS message retrieves the current position 
'of the progress bar.
'  wParam = 0
'  lParam = 0
'Returns a UINT that represents the current position 
'of the progress bar.  
Public Const PBM_GETPOS As Long = (WM_USER + 8)

'ProgressBarStyles 
Public Const PROGRESS_CLASS As String = "msctls_progress32"  
  
'These are available only if the version of 
'comctl32.dll is greater than 4.70 (IE3 and later)
Public Const PBS_SMOOTH As Long = &H1    
Public Const PBS_VERTICAL As Long = &H4 
 Comments
Save the above into a BAS module for use in the companion code page Creating the Common Control ProgressBarvia the API.

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter