Link to home
Start Free TrialLog in
Avatar of Milewskp
MilewskpFlag for Canada

asked on

How to change the Status Bar Text format

I know how to change the colour of the status bar text:
      Public Declare Function SetTextColor Lib "gdi32" _
      (ByVal hdc As Long, ByVal crColor As Long) As Long

But how can I change the font format to bold?
ASKER CERTIFIED SOLUTION
Avatar of Si Ball
Si Ball
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Milewskp

ASKER

Thanks Sudo!
Here's the procedure I created based on your help:
Public Sub SetSBTColors(Optional MyFont As String = "Tahoma", Optional Italics As Boolean = False, _
Optional Size As Integer = 11, Optional Weight As Integer = 400, Optional Forecolor As Variant, _
Optional Backcolor As Variant)
   'PURPOSE: This proc sets the font style and back color of the Status Bar window.
   '
   'ARGUMENTS:
   ' Weight is font weight; values: 0, 100, 200, ...900. 0 is 'don't care', 400 is normal, 700 is bold.
   '
   'CREDITS:
   'Based on code by:
   ' - Stephen Lebans (Lebans Holdings 1999 Ltd.), and
   ' - jonofisher (http://www.mrexcel.com/forum/showthread.php?p=733010).
   'Modified by MILEWSKP.
   
   Dim rc As RECT 'Window rectangle
   Dim hFont As Long, hFontOld As Long
   Dim hDcStatusBar As Long 'Status Bar's Device Context
   Dim hWndStatusBar As Long 'Handle to Status Bar window
   
   Const API_TRUE As Long = 1&
   
   'INITIALIZE
   
   'Get the Status Bar's window handle
   hWndStatusBar = FindWindowEx(Application.hWndAccessApp, 0&, "OStatbar", vbNullString)
   
   'Set the Status Bar's Device Context properties
   hDcStatusBar = GetDC(hWndStatusBar)
   
   'Get dimensions of the Status Bar window
   Call GetWindowRect(hWndStatusBar, rc)
   With rc
      .Bottom = .Bottom - .top
      .top = 0
      .right = .right - .Left
      .Left = 0
   End With
   
   'Use default colors?
   If IsMissing(Backcolor) Then Backcolor = GetSysColor(conSysBtnFace) 'Current system color (NOTE 1)
   If IsMissing(Forecolor) Then Forecolor = conBlack 'Black

   
   'SET FONT STYLE AND BACK COLOR
   
   'Set font style
   hFont = CreateFont(-1 * Size, 0, 0, 0, Weight, -1 * Italics, 0, 0, 0, 0, 0, 0, 0, MyFont)
   hFontOld = SelectObject(hDcStatusBar, hFont)
   
   'Set font color
   Call SetTextColor(hDcStatusBar, Forecolor)
   
   'Set SBT backcolor
   Call SetBkColor(hDcStatusBar, Backcolor)
   
   'Redraw the SBT
   Call InvalidateRect(hWndStatusBar, rc, API_TRUE)
   

'_________________________________________________________________________________
QuitSub:
   Call ReleaseDC(hWndStatusBar, hDcStatusBar) 'Release the Device Context
'_________________________________________________________________________________
'NOTES:
' 1. Can't include default value for BackColor in procedure header (only constants are allowed there).

End Sub

Open in new window

superb!

and in my good answer email:
Earn 4,308 more points, and you will become a Wizard in this zone!

very excited!