Page 1 of 1
Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 1:11 am
by BarryG
One of my users has bad vision and would like the selected PanelGadget tab to be in bold text, instead of default.
I tried this search but no matches ->
search.php?keywords=panelgadget+tab+text+bold
Any ideas? Thanks.
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 5:18 am
by RASHAD
Quick hack
Code: Select all
Global oldCallback
LoadFont(0,"Georgia",12,#PB_Font_Bold )
LoadFont(1,"Tahoma",10)
Procedure panelCB(hWnd, uMsg, wParam, lParam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_DRAWITEM
*Pan.DRAWITEMSTRUCT = lParam
If *Pan\CtlType = #ODT_TAB
sel = SendMessage_(GadgetID(0), #TCM_GETCURSEL, 0, 0)
Select *Pan\itemID
Case sel
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
SelectObject_(*Pan\hdc,FontID(0))
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
Default
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
SelectObject_(*Pan\hdc,FontID(1))
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 600,400, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget (0, 10,10, 580,380)
AddGadgetItem(0, -1, "Sub-Panel 1")
AddGadgetItem(0, -1, "Sub-Panel 2")
AddGadgetItem(0, -1, "Sub-Panel 3")
CloseGadgetList()
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TCS_OWNERDRAWFIXED)
oldCallback = SetWindowLongPtr_(GetParent_(GadgetID(0)), #GWL_WNDPROC, @panelCB())
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 5:53 am
by BarryG
Thank you so much, Rashad! I will adapt for my needs.

Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 6:35 am
by RASHAD
You are welcome
With RED color also
Code: Select all
Global oldCallback
LoadFont(0,"Georgia",12,#PB_Font_Bold )
LoadFont(1,"Tahoma",10)
Procedure panelCB(hWnd, uMsg, wParam, lParam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_DRAWITEM
*Pan.DRAWITEMSTRUCT = lParam
If *Pan\CtlType = #ODT_TAB
sel = SendMessage_(GadgetID(0), #TCM_GETCURSEL, 0, 0)
Select *Pan\itemID
Case sel
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
SelectObject_(*Pan\hdc,FontID(0))
SetTextColor_(*Pan\hdc,$0000FF)
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
Default
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
SelectObject_(*Pan\hdc,FontID(1))
SetTextColor_(*Pan\hdc,$000000)
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
EndSelect
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 600,400, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget (0, 10,10, 580,380)
AddGadgetItem(0, -1, "Sub-Panel 1")
AddGadgetItem(0, -1, "Sub-Panel 2")
AddGadgetItem(0, -1, "Sub-Panel 3")
CloseGadgetList()
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TCS_OWNERDRAWFIXED)
oldCallback = SetWindowLongPtr_(GetParent_(GadgetID(0)), #GWL_WNDPROC, @panelCB())
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 6:58 am
by Paul
Just hope that none of your users have a 4K monitor when using this code or they'll have a whole other problem with reading the tabs

Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 8:40 am
by RASHAD
That is very strange
I do have 4K LG Monitor 3840x2160 Scale 150%
PB 6.21 x64 Windows 11 x64
Did all the variation without any problem
Any how next is a Workaround
Code: Select all
LoadFont(0,"Georgia",14,#PB_Font_Bold)
If OpenWindow(0, 0, 0, 600, 400, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget (0, 10, 10, 580,380)
AddGadgetItem(0, -1, "Panel 1")
AddGadgetItem(0, -1, "Panel 2")
AddGadgetItem(0, -1, "Panel 3")
CloseGadgetList()
TextGadget(10,0,0,0,0,"",#WS_CLIPSIBLINGS|#SS_CENTERIMAGE|#SS_CENTER)
;***************************************************************************************************
;Fix for PB 6.21 just in case
;SetWindowLongPtr_(GadgetID(10),#GWL_STYLE ,GetWindowLongPtr_(GadgetID(10),#GWL_STYLE)&~ #SS_NOTIFY)
;****************************************************************************************************
SetGadgetColor(10, #PB_Gadget_BackColor,$FFFFFF)
SetGadgetColor(10, #PB_Gadget_FrontColor,$0000FF)
SetGadgetFont(10,FontID(0))
SetWindowPos_(GadgetID(10), #HWND_TOP, 0,0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
act = GetGadgetState(0)
SendMessage_(GadgetID(0),#TCM_GETITEMRECT,act,p.RECT)
tabw = p\right-p\left
tabh = p\bottom-p\top
SetGadgetText(10,GetGadgetItemText(0,act))
MoveWindow_(GadgetID(10),p\left+12,p\top+12,tabw,tabh,1)
EndSelect
EndSelect
Until Quit = 1
EndIf
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 10:05 am
by BarryG
Paul wrote: Sun Nov 16, 2025 6:58 amJust hope that none of your users have a 4K monitor when using this code or they'll have a whole other problem with reading the tabs
Yep, that's why I said I'll adapt it (to use the default system font).
RASHAD wrote: Sun Nov 16, 2025 8:40 amAny how next is a Workaround
Not really:
Here's how I adapted Rashad's code for use in my app:
Code: Select all
Global oldCallback
LoadFont(0,"Microsoft Sans Serif",10,#PB_Font_Bold)
LoadFont(1,"Microsoft Sans Serif",10)
Procedure panelCB(hWnd, uMsg, wParam, lParam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_DRAWITEM
*Pan.DRAWITEMSTRUCT = lParam
If *Pan\CtlType = #ODT_TAB
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
If *Pan\itemID = SendMessage_(GadgetID(0), #TCM_GETCURSEL, 0, 0) ; Selected panel tab.
SelectObject_(*Pan\hdc,FontID(0))
Else ; All other panel tabs.
SelectObject_(*Pan\hdc,FontID(1))
EndIf
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 600,400, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget (0, 10,10, 580,380)
AddGadgetItem(0, -1, "Sub-Panel 1")
AddGadgetItem(0, -1, "Sub-Panel 2")
AddGadgetItem(0, -1, "Sub-Panel 3")
CloseGadgetList()
SetGadgetFont(0,FontID(0))
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TCS_OWNERDRAWFIXED)
oldCallback = SetWindowLongPtr_(GetParent_(GadgetID(0)), #GWL_WNDPROC, @panelCB())
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
Which gives me this:
Although... I just noticed this puts a line under the current selected tab, where it doesn't normally have one.

Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 11:15 am
by Lord
May I just jump in?
What if I want to have the text in tabs constantly colored?
Maybe first tab red, second blue and third green?
It should be when the PanelGadget with its tabs is created.
Is this possible?
Thanks in advance.
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 11:36 am
by wombats
Lord wrote: Sun Nov 16, 2025 11:15 am
May I just jump in?
What if I want to have the text in tabs constantly colored?
Maybe first tab red, second blue and third green?
It should be when the PanelGadget with its tabs is created.
Is this possible?
Thanks in advance.
Something like this? I edited BarryG's code.
Code: Select all
Global oldCallback
LoadFont(0,"Microsoft Sans Serif",10,#PB_Font_Bold)
LoadFont(1,"Microsoft Sans Serif",10)
Procedure panelCB(hWnd, uMsg, wParam, lParam)
result = CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_DRAWITEM
*Pan.DRAWITEMSTRUCT = lParam
If *Pan\CtlType = #ODT_TAB
tabText$ = GetGadgetItemText(0, *Pan\itemID, 0)
textColor = GetGadgetItemData(0, *pan\itemID)
If *Pan\itemID = SendMessage_(GadgetID(0), #TCM_GETCURSEL, 0, 0) ; Selected panel tab.
SelectObject_(*Pan\hdc,FontID(0))
Else ; All other panel tabs.
SelectObject_(*Pan\hdc,FontID(1))
EndIf
SetTextColor_(*Pan\hDC, textColor)
DrawText_(*Pan\hdc, tabText$, Len(tabText$), *Pan\rcItem, #DT_CENTER | #DT_SINGLELINE | #DT_VCENTER | #DT_NOCLIP)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 600,400, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget (0, 10,10, 580,380)
AddGadgetItem(0, -1, "Item 1")
SetGadgetItemData(0, CountGadgetItems(0) - 1, RGB(255, 0, 0))
AddGadgetItem(0, -1, "Item 2")
SetGadgetItemData(0, CountGadgetItems(0) - 1, RGB(0, 0, 255))
AddGadgetItem(0, -1, "Item 3")
SetGadgetItemData(0, CountGadgetItems(0) - 1, RGB(37, 177, 76))
CloseGadgetList()
SetGadgetFont(0,FontID(0))
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TCS_OWNERDRAWFIXED)
oldCallback = SetWindowLongPtr_(GetParent_(GadgetID(0)), #GWL_WNDPROC, @panelCB())
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
Re: Make selected PanelGadget tab bold?
Posted: Sun Nov 16, 2025 11:49 am
by BarryG
Nice, wombats!
