|
-
Apr 28th, 2000, 01:01 AM
#1
I'm looking for some help on how to embed a progressbar into a statusbar control on an MDI form. I've attempted using some of the API examples but the move method doesn't seem to be working properly. The ProgressBar appears right below my button bar instead of showing up within the StatusBar pannel.
-
Apr 28th, 2000, 02:38 AM
#2
Sure. You can use this procedure I wrote a while back:
Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const WM_USER As Long = &H400
Private Const SB_GETRECT As Long = (WM_USER + 10)
Public Sub ShowProgressInStatus(pProgress As ProgressBar, pStatus As StatusBar, pPanelIndex As Integer)
Dim tRC As RECT
pProgress.Appearance = ccFlat
'Get the size of the given panel
SendMessage StatusBar1.hwnd, SB_GETRECT, pPanelIndex - 1, tRC
'Convert to Twips
With tRC
.Top = (.Top * Screen.TwipsPerPixelY) + 20
.Left = (.Left * Screen.TwipsPerPixelX) + 20
.Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
.Right = (.Right * Screen.TwipsPerPixelX) - .Left - 20
End With
'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
Then you can call it like this:
ShowProgressInStatus Progress1, Status1, 1
This will put ProgressBar into the first panel of the StatusBar.
-
Apr 28th, 2000, 03:55 AM
#3
I'm looking for some help on how to embed a progressbar into a statusbar control on an MDI form. I've attempted using some of the API examples but the move method doesn't seem to be working properly. The ProgressBar appears right below my button bar instead of showing up within the StatusBar pannel.
I'm afraid this isn't working for me... I've cut and pasted the code and modified where you had statusbar1 and panelbar1 to use the pStatus and pPanel parameters however I'm still having the same problems. Just as an FYI I'm running on NT, so I'm not sure if there is a difference in regrads to the API calls. Lastly, I created a cmdButton and have that increment to 1000 in order to test the progress bar. When I click on the button the ENTIRE status bar looks as if it's being painted over but you can't see any tick marks. Lastly, you can see a rectangular frame above the statusbar...
Any ideas????
-
Apr 28th, 2000, 05:14 AM
#4
It is working just fine. In order for you to see the Progress, you will have to change it's value. Here is an example. Drop a Timer control on the form and use this code:
Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const WM_USER As Long = &H400
Private Const SB_GETRECT As Long = (WM_USER + 10)
Public Sub ShowProgressInStatus(pProgress As ProgressBar, pStatus As StatusBar, pPanelIndex As Integer)
Dim tRC As RECT
pProgress.Appearance = ccFlat
'Get the size of the given panel
SendMessage StatusBar1.hwnd, SB_GETRECT, pPanelIndex - 1, tRC
'Convert to Twips
With tRC
.Top = (.Top * Screen.TwipsPerPixelY) + 20
.Left = (.Left * Screen.TwipsPerPixelX) + 20
.Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
.Right = (.Right * Screen.TwipsPerPixelX) - .Left - 20
End With
'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
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
ShowProgressInStatus ProgressBar1, StatusBar1, 1
End Sub
Private Sub Timer1_Timer()
With ProgressBar1
If .Value = .Max Then
.Value = .Min
Else
.Value = .Value + 1
End If
End With
End Sub
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
|