[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to change the Status Bar Text format

Posted on 2011-09-14
3
Medium Priority
?
619 Views
Last Modified: 2013-11-29
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?
0
Comment
Question by:Milewskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Simon Ball earned 2000 total points
ID: 36542273
I foudn an old excel forum thread which details setting font weight in the status bar:

http://www.mrexcel.com/forum/showthread.php?p=733010
Looks like you have to create a font object to apply to the status bar font property....

See the function createFont and

look for this line:

'// Save old Font First!
 hFontOld = SelectObject(hDcStatusBar, hFont)

and this:

hFont = CreateFont(-12, 0, 0, 0, fnWeight.FW_ULTRALIGHT, 1, 0, 0, 0, 0, 0, 0, 0, _
 "MS SansSerif ")



Seems a long winded process....


'// Font weight of the font in the range 0 through 1000.
 '// For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
 Enum fnWeight
 FW_DONTCARE = 0
 FW_THIN = 100
 FW_EXTRALIGHT = 200
 FW_ULTRALIGHT = 200
 FW_LIGHT = 300
 FW_NORMAL = 400
 FW_REGULAR = 400
 FW_MEDIUM = 500
 FW_SEMIBOLD = 600
 FW_DEMIBOLD = 600
 FW_BOLD = 700
 FW_EXTRABOLD = 800
 FW_ULTRABOLD = 800
 FW_HEAVY = 900
 FW_BLACK = 900
 End Enum

Open in new window

0
 
LVL 1

Author Comment

by:Milewskp
ID: 36543889
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

0
 
LVL 15

Expert Comment

by:Simon Ball
ID: 36544373
superb!

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

very excited!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question