Click to See Complete Forum and Search --> : Serge, or anyone else that knows
Inhumanoid
Dec 5th, 1999, 05:24 PM
http://www.vb-world.net/ubb/Forum1/HTML/011402.html
I don't get the sngBorderWidth part....
[This message has been edited by Inhumanoid (edited 12-06-1999).]
Serge
Dec 5th, 1999, 07:05 PM
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:
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
[This message has been edited by Serge (edited 12-06-1999).]
Vynia
Dec 13th, 1999, 08:21 PM
I put a progress bar into the second panel of my statusbar the way Serge described it. I set the bevel of the panel to sbrInset but when the progress bar is displayed, the inset-frame just disappears. How can I prevent it from doing this?
Thanx in advance, Marc D. Migge
Serge
Dec 13th, 1999, 09:03 PM
Thats ok, we can tweak it a little.
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
ShowProgressInStatus Progress1, Status1, 1
Now you it will look like its actually inside of the status bar.
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Vynia
Dec 13th, 1999, 09:18 PM
Thanx, Serge. I tried:
.Top = (.Top+1 * Screen.TwipsPerPixelY)
.Left = (.Left+1 * Screen.TwipsPerPixelX)
.Bottom = (.Bottom-1 * Screen.TwipsPerPixelY)
.Right = (.Right-1 * Screen.TwipsPerPixelX)
before and I got an error. But now I realize my mistake:
.Top = ((.Top+1) * Screen.TwipsPerPixelY)
.Left = (.Left+1) * Screen.TwipsPerPixelX)
.Bottom = ((.Bottom-1)*Screen.TwipsPerPixelY)
.Right = ((.Right-1) * Screen.TwipsPerPixelX)
should work as well...
Thanx again, Marc D. Migge
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.