Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Status Bar Control 1

Status
Not open for further replies.

sacsac

Programmer
Dec 10, 2000
182
GB
I always use the Status Bar control displaying at the bottom of my application MDI form, usually with several panels giving the user a constant display of important information. Is there any way to make the text in just ONE panel a different color and/or font?
 
Here's a sample of what you are looking for. There are probably better ways, but this is what I do.

Create a form with...

1. status bar (StatusBar1)
2. Picture Box (Picture1)
3. Label INSIDE the picture box (Label1)



Option Explicit

'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 bCancelSend As Boolean

Private Sub Form_Load()

Dim tRC As RECT

'
' 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, 0, 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 Picture1
SetParent .hwnd, StatusBar1.hwnd
.Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom
.Visible = True
End With

Label1.Top = 0
Label1.Left = 0
Label1.Width = Picture1.ScaleWidth
Label1.Height = Picture1.ScaleHeight

Label1.Caption = "This is my text."
Label1.ForeColor = vbRed
Label1.FontBold = True

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top