[Solved] Difficulties with StatusBar
Posted: Sat Nov 08, 2025 9:14 pm
Hello everyone again.
I also wanted to say that I am experiencing difficulties when working with StatusBar. Why can't I choose a font style for the StatusBar ? Maybe I missed something ?
I have to use this old code:
The default font is too small. When switching focus or minimizing a window, text disappears from the StatusBar fields. A similar issue was recently discussed here, but it didn't involve the StatusBar. I have to remember the state of each field and periodically update the contents of the StatusBar. This is very inconvenient. Moreover, it requires additional work to track events such as window minimization, overlapping with another window, etc. And still I couldn't get it to work properly. I also saw some great code from mk-soft (handmade StatusBar). I just saw this work recently. This is great, but it requires some code rework.
By the way... there was a trick here for getting text from any StatusBar field. So... It doesn't work with this code!
Could someone take a look at this code ? What could be causing this behavior ? I haven't seen any specific pattern.
Thanks in advance.
I also wanted to say that I am experiencing difficulties when working with StatusBar. Why can't I choose a font style for the StatusBar ? Maybe I missed something ?
I have to use this old code:
Code: Select all
; Title: Custom Statusbar Text Colors
; Author: Fluid Byte
; Date: December 28, 2006
Structure ODSBTEXT
szText.l
clrFront.l
EndStructure
Global font
font = LoadFont(#PB_Any, "FixedSys", 14)
Procedure WindowCallback(hWnd.l,uMsg.l,wParam.l,lParam.l)
Select uMsg
Case #WM_DRAWITEM
*lpdis.DRAWITEMSTRUCT = lParam
ClassName$ = Space(19) : GetClassName_(*lpdis\hwndItem,ClassName$,19)
If ClassName$ = "msctls_statusbar32"
*osbt.ODSBTEXT = *lpdis\itemData
SelectObject_(*lpdis\hDC,FontID(font))
SetTextColor_(*lpdis\hDC,*osbt\clrFront)
;SetBkColor_(*lpdis\hDC, #TRANSPARENT)
SetBkMode_(*lpdis\hDC, #TRANSPARENT)
SendMessage_(*lpdis\hwndItem,#SB_GETBORDERS,0,aBorders.RECT)
InflateRect_(*lpdis\rcItem,-aBorders\right / 2,0)
DrawText_(*lpdis\hDC,*osbt\szText,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,350,100,"Custom Statusbar Text Colors",#WS_OVERLAPPEDWINDOW | 1)
SetWindowCallback(@WindowCallback())
Result = CreateStatusBar(0,WindowID(0))
AddStatusBarField(100) : StatusBarText(0,0,"Statusbar Field #1")
AddStatusBarField(100) : StatusBarText(0,1,"Statusbar Field #2")
AddStatusBarField(100)
osbt.ODSBTEXT
osbt\szText = @"Statusbar Field #3"
osbt\clrFront = #Black
;osbt\clrBack = #Black
SendMessage_(Result,#SB_SETTEXT,2 | #SBT_OWNERDRAW,osbt)
While WaitWindowEvent() ! 16 : WendBy the way... there was a trick here for getting text from any StatusBar field. So... It doesn't work with this code!
Could someone take a look at this code ? What could be causing this behavior ? I haven't seen any specific pattern.
Thanks in advance.