[Windows, Solved] Changing StatusBar field width
Posted: Sat Feb 14, 2026 9:17 am
I'd like to change the width of some statusbar fields but wondering why a progressbar won't be affected (or effected?) automatically.
The following example shows that text fields are updated as wanted (top button) but when changing the field to a progress bar (press bottom button once) changing the width seems to be ignored.
// Edited post title - Marked as solved //
The following example shows that text fields are updated as wanted (top button) but when changing the field to a progress bar (press bottom button once) changing the width seems to be ignored.
Code: Select all
; Define
#PB_DpiBits= 16
#PB_DpiScale= 1<<#PB_DpiBits
Global DpiScale=GetDeviceCaps_(GetDC_(0),#LOGPIXELSX)<<#PB_DpiBits/96; 12 Bit (statt Fließkommaberechnung)
Macro ScaleUp(value)
(((value)*DpiScale)/#PB_DpiScale)
EndMacro
Macro ScaleDown(value)
(((value)<<#PB_DpiBits)/DpiScale)
EndMacro
; EndDefine
Procedure StatusBarFieldWidth(StatusBar,Field.i,Width.l)
If IsStatusBar(StatusBar)
Protected StatusBarID=StatusBarID(StatusBar)
Protected nParts,lResult
Protected lLeftField.l
Protected *dwFields
nParts=SendMessage_(StatusBarID,#SB_GETPARTS,0,0)
*dwFields=AllocateMemory(nParts*4)
If *dwFields
SendMessage_(StatusBarID,#SB_GETPARTS,nParts,*dwFields)
If Field>0
lLeftField=PeekL(*dwFields+(Field-1)*4)
EndIf
PokeL(*dwFields+Field*4,lLeftField+ScaleUp(Width))
lResult=SendMessage_(StatusBarID, #SB_SETPARTS,nParts,*dwFields)
FreeMemory(*dwFields)
ProcedureReturn lResult
EndIf
ProcedureReturn #False
EndIf
EndProcedure
OpenWindow(0,0,0,600,400,"Progress Bar", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(ScaleUp(20))
AddStatusBarField(ScaleUp(200))
AddStatusBarField(#PB_Ignore)
StatusBarText(0,0,">")
StatusBarText(0,1,"|---MOVE---|")
StatusBarText(0,2,"<")
ButtonGadget(1,200,120,200,50,"Toggle Width")
ButtonGadget(2,200,200,200,50,"Toggle Text/Progress Bar")
w=20
p=0
Repeat
lEvent = WaitWindowEvent()
Select lEvent
Case #PB_Event_Gadget
Select EventGadget()
Case 1
w=120-w
StatusBarFieldWidth(0,0,w)
StatusBarFieldWidth(0,1,220-w)
Case 2
p!1
If p
StatusBarProgress(0,1,50)
Else
StatusBarText(0,1,"|---MOVE---|")
EndIf
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
// Edited post title - Marked as solved //