|
' StatusProgressBar class
'
' To put a progressbar in a statusbar panel in a VB.Net project
' E. Marcon, jan. 2004
' http://e.marcon.free.fr
Class StatusProgressBar
Public ProgressBar As ProgressBar ' The progressbar
Public StatusBar As StatusBar ' The Statusbar
Public Panel As Int16 ' The status panel
Public Margin As Int32 ' The margin between the panel's edge and the progressbar
' API SendMaessageA in User32: returns the rectangle (RECT structure) used to display a status-bar panel
' Parameters are the statusbar's handle, the "Get Rectangle" message, the panel's number, and the RECT structure to return the values
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal msg As Int32, ByVal wParam As Int32, ByRef lParam As RECT) As Long
Private Const WM_USER As Long = &H400
Private Const SB_GETRECT As Long = (WM_USER + 10)
' RECT structure to get the panel's display rectangle
Private Structure RECT
Friend Left As Int32
Friend Top As Int32
Friend Right As Int32
Friend Bottom As Int32
End Structure
Public Sub New(ByRef pgb As ProgressBar, ByRef sb As StatusBar, Optional ByRef intPanelNumber As Int16 = 0, Optional ByVal intMargin As Int32 = 2)
' Puts a progress bar in a statusbar's panel
' Affects the progressbar to the class members
ProgressBar = pgb
StatusBar = sb
Panel = intPanelNumber
' Sets the margin between the statusbar panel edge and the progressbar
Margin = intMargin
' Reparent it
ProgressBar.Parent = StatusBar
' Set the size
Resize()
' Set it visible
ProgressBar.Visible = True
End Sub
Public Sub Resize()
'Fits the progress bar to the status bar
Dim Rectangle As RECT
' Use the API to get the panel's display rectangle
SendMessage(StatusBar.Handle.ToInt32, SB_GETRECT, Panel, Rectangle)
' Resize
With ProgressBar
.Left = Rectangle.Left + Margin
.Top = Rectangle.Top + Margin
.Height = Rectangle.Bottom - Rectangle.Top - 2 * Margin
.Width = Rectangle.Right - Rectangle.Left - 2 * Margin
End With
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.