StatusBar Disabled Look

Just starting out? Need help? Post your questions and find answers here.
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: StatusBar Disabled Look

Post 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
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5044
Joined: Sun Apr 12, 2009 6:27 am

Re: StatusBar Disabled Look

Post 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
Egypt my love
JHPJHP
Addict
Addict
Posts: 2285
Joined: Sat Oct 09, 2010 3:47 am

Re: StatusBar Disabled Look

Post 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. :P

Cheers,

NB*: I only added...

Code: Select all

FontID = SendMessage_(hStatusBar, #WM_GETFONT, 0, 0)
DrawingFont(FontID)
... to fit my needs perfectly.
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Re: StatusBar Disabled Look

Post by garretthylltun »

This post should be in Tips & Tricks section.

Thank you Shardik and RASHAD
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
Post Reply