|
-
Dec 5th, 1999, 08:05 PM
#2
This variable is calculating the thinkness of the border. So when you place the Progress bar on the Status bar it will actually will be inside of the Status bar and not just on it. If you remove that variable, you will see what I mean. This VB way is short but not actually the right way, because it makes you think that Progress bar is a child for a Status bar, where actually it is NOT. If you want to use the right way, use API:
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
'Get the size of the given panel
SendMessage StatusBar1.hwnd, SB_GETRECT, pPanelIndex - 1, tRC
'Convert to Twips
With tRC
.Top = (.Top * Screen.TwipsPerPixelY)
.Left = (.Left * Screen.TwipsPerPixelX)
.Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top
.Right = (.Right * Screen.TwipsPerPixelX) - .Left
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
Usage: ShowProgressInStatus ProgressBar, StatusBar, PanelIndex
Example: ShowProgressInStatus Progress1, Status1, 1
This will pu the Progress bar in the first panel (Panel index is 1 based)
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 12-06-1999).]
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
|