Advanced & Simple StatusBar (Windows)

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4637
Joined: Sun Apr 12, 2009 6:27 am

Advanced & Simple StatusBar (Windows)

Post by RASHAD »

The title say it all

# 1:

Code: Select all

LoadFont (1, "Arial", 14,#PB_Font_Italic)
LoadFont (2, "Tahoma", 8,#PB_Font_Underline)
LoadFont (3, "Broadway", 16)

If OpenWindow(0, 0, 0, 400, 100, "PureBasic - StatusBar Example", #PB_Window_SystemMenu |  #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  
  CreateStatusBar(0, WindowID(0))
  SendMessage_(StatusBarID(0), #SB_SETMINHEIGHT, 38, 0)
  SendMessage_(StatusBarID(0), #WM_SIZE, 0,0)
  AddStatusBarField(100)
  AddStatusBarField(100)
  AddStatusBarField(100)
  
  ContainerGadget(0,1,1,300,36)
  TextGadget(1,0,0,100,38,"TEST",#SS_CENTER|#SS_CENTERIMAGE|#WS_DLGFRAME)
  SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
  SetGadgetColor(1,#PB_Gadget_BackColor,$C0FEFD)
  SetGadgetFont(1,FontID(1))
  TextGadget(2,99,0,100,38,"TEST OK",#SS_CENTER|#SS_CENTERIMAGE|#WS_DLGFRAME)
  SetGadgetColor(2,#PB_Gadget_FrontColor,$FFFFFF)
  SetGadgetColor(2,#PB_Gadget_BackColor,$0)
  SetGadgetFont(2,FontID(2))
  TextGadget(3,198,0,103,38,"TEST 3",#SS_CENTER|#SS_CENTERIMAGE|#WS_DLGFRAME)
  SetGadgetColor(3,#PB_Gadget_FrontColor,$0FFE03)
  SetGadgetFont(3,FontID(3))
  CloseGadgetList()  
  SetParent_(GadgetID(0),StatusBarID(0))
  AddWindowTimer(0,125,800)
  fcolor = GetGadgetColor(2,#PB_Gadget_FrontColor ) 
  bcolor = GetGadgetColor(2,#PB_Gadget_BackColor )   
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Timer
        Run ! 1        
        fcolor = fcolor ! 255
        bcolor = bcolor ! 255
        If Run = 1
          SetGadgetText(2,"ERROR")
        Else
          SetGadgetText(2,"TEST OK")
        EndIf
        SetGadgetColor(2,#PB_Gadget_FrontColor,fcolor)
        SetGadgetColor(2,#PB_Gadget_BackColor,bcolor )
        
    EndSelect        
    
  Until Quit = 1
  
EndIf 
# 2:

Code: Select all

LoadFont(0,"Georgia",16,#PB_Font_Bold | #PB_Font_Italic )

If OpenWindow(0, 100, 150, 800, 400, "PureBasic - StatusBar Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered| #PB_Window_SizeGadget)

  If CreateStatusBar(0, WindowID(0))
    AddStatusBarField(750 )
  EndIf
  sbHwnd = StatusBarID(0)
  SendMessage_(sbHwnd, #SB_SETMINHEIGHT, 30, 0)
  SendMessage_(sbHwnd, #WM_SIZE, 0,0)
  UseGadgetList(sbHwnd)
  cont = ContainerGadget(#PB_Any,1,1,600,28)
    TextGadget(0,0,0,200,30," Test 4 Status",#WS_BORDER|#SS_NOTIFY | #SS_CENTER|#SS_CENTERIMAGE)
    GadgetToolTip(0," Current Status ")
    SetGadgetColor(0,#PB_Gadget_BackColor,$CCFEFC)
    SetGadgetColor(0,#PB_Gadget_FrontColor,$0000FF)
    SetGadgetFont(0,FontID(0))
    TrackBarGadget(1,200,0,150,28,0,100)    
    StringGadget(2,350,0,200,30,"TEST")
  CloseGadgetList()
  UseGadgetList(WindowID(0))
  ButtonGadget(10,10,10,80,24,"RUN")
Repeat   
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Debug GetGadgetState(1)
          
        Case 10
          SetGadgetText(0,"New Text")
      EndSelect
        
  EndSelect
Until Quit = 1
  
EndIf 
Have fun
Last edited by RASHAD on Mon Jul 19, 2021 8:23 am, edited 1 time in total.
Egypt my love
BarryG
Addict
Addict
Posts: 3294
Joined: Thu Apr 18, 2019 8:17 am

Re: Advanced & Simple StatusBar (Windows)

Post by BarryG »

Nice! Thanks, Rashad.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4637
Joined: Sun Apr 12, 2009 6:27 am

Re: Advanced & Simple StatusBar (Windows)

Post by RASHAD »

Thanks BarrG
But sorry guys just discovered that I am not the first one who used such tech. but at least 2 other fellows I am one of them :mrgreen:
It seems that I am getting older
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Advanced & Simple StatusBar (Windows)

Post by Kwai chang caine »

Useful code RASHAD :D
Works nice here
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply