|
-
Oct 9th, 2000, 10:14 AM
#1
Thread Starter
Fanatic Member
hi,
i am wanting to use a progress bar in my next program and i was wondering what code i need to include in one to get it to work and how can i make events happen when the progress bar is a t a certain posistion
Cheers
Merlin ?
BTW can you include code
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Oct 9th, 2000, 10:25 AM
#2
Lively Member
taken from the net
Code:
You can add a Windows Like progress bar to your programs. Just add the MS Windows Common Controls 5.0 OCX (comctl32.ocx) to your project and add the progress bar to your form.
The most important properties you need to know are:
Min: The minimum value of the bar.
Max: The maximum value of the bar.
Value: The current value of the bar. It determines how much of the bar is filled.
Usually is better to work with percent values so the min value is zero and the max is 100.
Here is a little example of how to use the progress bar:
Add a Progress bar and a command Button to your form an add the following code to the click event of the Command Button:
Private Sub Command1_Click()
Dim x As Integer, y As Integer
For x = 1 To 100
For y = 1 To 1000
ProgressBar1.Value = x
Next y
Next x
End Sub
-
Oct 9th, 2000, 10:39 AM
#3
Thread Starter
Fanatic Member
cheers i will give it a go
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Oct 9th, 2000, 11:04 AM
#4
Frenzied Member
To place a progressbar in a Statusbar:
Code:
'This tip was written by Chris Eastwood (www.codeguru.com/vb/) To use this tip add a form with a progress bar, a status bar and a command button on. Copy the following code into the form's General Declarations procedure:
'Declarations
'
' API Declarations
'
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As _
Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam _
As Any) As Long
'
' API Types
'
' RECT is used to get the size of the panel we're inserting into
'
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'
' API Messages
'
Private Const WM_USER As Long = &H400
Private Const SB_GETRECT As Long = (WM_USER + 10)
Private Sub ShowProgressInStatusBar(ByVal bShowProgressBar As Boolean)
Dim tRC As RECT
If bShowProgressBar Then
'
' Get the size of the Panel (2) Rectangle from the status bar
' remember that Indexes in the API are always 0 based (well,
' nearly always) - therefore Panel(2) = Panel(1) to the api
'
'
SendMessageAny StatusBar1.hwnd, SB_GETRECT, 1, tRC
'
' and convert it to twips....
'
With tRC
.Top = (.Top * Screen.TwipsPerPixelY)
.Left = (.Left * Screen.TwipsPerPixelX)
.Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
.Right = (.Right * Screen.TwipsPerPixelX) - .Left
End With
'
' Now Reparent the ProgressBar to the statusbar
'
With ProgressBar1
SetParent .hwnd, StatusBar1.hwnd
.Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
.Visible = True
.Value = 0
End With
Else
'
' Reparent the progress bar back to the form and hide it
'
SetParent ProgressBar1.hwnd, Me.hwnd
ProgressBar1.Visible = False
End If
End Sub
Private Sub Command1_Click()
'Call the function
Call ShowProgressInStatusBar(True)
'Do something in the progress bar
For i = 1 To ProgressBar1.Max
ProgressBar1.Value = i
Next i
End Sub
And here's how to make your own:
http://www.mvps.org/vbnet/code/neet/bitbltflood.htm
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|