Page 1 of 1
StatusBar Disabled Look
Posted: Wed Jul 24, 2013 8:36 am
by JHPJHP
Is there a way to set a status bar field to disabled?
I've tried using SendMessage, but all I can get it to do is modify the Text & Font...
It's probably worth noting that I have "XP skin support" enabled in the options...
(I know this affects some settings - ie. #CCM_SETBKCOLOR)
Thank you,
Code: Select all
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(200)
AddStatusBarField(#PB_Ignore)
AddStatusBarField(100)
AddStatusBarField(150)
StatusBarText(0, 3, "Capturing", #PB_StatusBar_Center)
EndIf
SendMessage_(StatusBarID(0), #CCM_SETBKCOLOR, 0, $FF)
Re: StatusBar Disabled Look
Posted: Wed Jul 24, 2013 10:04 am
by RASHAD
Hi
Workaround for windows
Code: Select all
If OpenWindow(0, 0, 0, 600, 400, "PureBasic - StatusBar Example", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(200)
AddStatusBarField(100)
AddStatusBarField(160)
StatusBarText(0,0,"For Test # 0")
StatusBarText(0,1,"For Test # 1")
StatusBarText(0,2,"For Test # 2",#PB_StatusBar_Center)
TextGadget(1,201,2,98,20,"For Test # 1",#SS_CENTERIMAGE | #SS_CENTER)
SetParent_(GadgetID(1),StatusBarID(0))
DisableGadget(1,1)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: StatusBar Disabled Look
Posted: Wed Jul 24, 2013 10:32 am
by JHPJHP
What a smart workaround - thank you!
Re: StatusBar Disabled Look
Posted: Wed Jul 24, 2013 12:27 pm
by Shardik
Another example using
a callback from Fluid Byte:
Code: Select all
Structure ODSBTEXT
szText.l
clrFront.l
clrBack.l
EndStructure
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
SetTextColor_(*lpdis\hDC,*osbt\clrFront)
SetBkColor_(*lpdis\hDC,*osbt\clrBack)
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, 100, 100, 250, 50, "StatusBar", #PB_Window_SizeGadget | #PB_Window_SystemMenu)
SetWindowCallback(@WindowCallback())
CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(100)
StatusBarText(0, 0, "Enabled")
StatusBarText(0, 1, "Disabled")
osbt.ODSBTEXT
osbt\szText = @"Disabled"
osbt\clrBack = GetSysColor_(#COLOR_3DFACE)
osbt\clrFront = #Gray
SendMessage_(StatusBarID(0), #SB_SETTEXT, 1 | #SBT_OWNERDRAW, osbt)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: StatusBar Disabled Look
Posted: Wed Jul 24, 2013 1:20 pm
by RASHAD
Another approach
Code: Select all
CreateImage(0,100,20)
StartDrawing(ImageOutput(0))
Box(0,0,100,20,GetSysColor_(#COLOR_3DFACE))
FrontColor($B8B8B8)
DrawingMode(#PB_2DDrawing_Transparent);|#PB_2DDrawing_Outlined)
DrawText(10,2,"Disabled")
StopDrawing()
OpenWindow(0, 0, 0, 400, 200, "StatusBar", #PB_Window_SizeGadget | #PB_Window_SystemMenu| #PB_Window_ScreenCentered)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(100)
AddStatusBarField(100)
StatusBarText(0, 0, "Enabled")
StatusBarImage(0, 1, ImageID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: StatusBar Disabled Look
Posted: Wed Jul 24, 2013 7:11 pm
by JHPJHP
Shardik thank you for the post, a perfect solution - and I do love callbacks!
But, how can I pass up a near complete PB solution that offers the same functionality... RASHAD does it again.
Cheers,
NB*: I only added...
Code: Select all
FontID = SendMessage_(hStatusBar, #WM_GETFONT, 0, 0)
DrawingFont(FontID)
... to fit my needs perfectly.
Re: StatusBar Disabled Look
Posted: Wed Jan 08, 2014 8:25 pm
by garretthylltun
This post should be in Tips & Tricks section.
Thank you Shardik and RASHAD