StatusBar background color.

Windows specific forum
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

StatusBar background color.

Post by dibor »

Hello guys.
How can I set StatusBar background color as window color?
PureBasic do not has any command for status bar color changing.
Please provide small and simple example if possible.
I am not programmer and use this compiler for small hamradio programs.

Best Wishes.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: StatusBar background color.

Post by skywalk »

Search for ts-soft example using canvas gadget statusbar. You get way more flexibility and control.
Do not try the statusbar direct approach since it will be more complicated with os specific callbacks and subclassing and api cmd's.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: StatusBar background color.

Post by dibor »

Tnx for answer.
ts-soft ???
Maybe mk-soft?
Anyway, do not find any example :(
Give me link if U have.

Thank U
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: StatusBar background color.

Post by davido »

@dibor,

Thorsten1867 has designed a canvas version. I haven't used it myself, but I have used a few of his other canvas-based gadgets and found them very useful, to me!
Please take a look at the following link: viewtopic.php?p=534381#p534381
DE AA EB
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: StatusBar background color.

Post by Paul »

This was posted way back when for Windows...

Code: Select all

; Title:  Custom Statusbar Text Colors
; Author: Fluid Byte/RASHAD
; Date:   December 28, 2006

Structure ODSBTEXT
   szText.s
   clrFront.i
   hBrush.i
EndStructure

Global Result
Global Dim osbt.ODSBTEXT(5)

Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
  Select uMsg
    Case #WM_DRAWITEM
      If wParam = GetDlgCtrlID_(Result)
        *lpdis.DRAWITEMSTRUCT = lParam  
        *osbt.ODSBTEXT = *lpdis\itemData       
        SetTextColor_(*lpdis\hDC, *osbt\clrFront)
        SetBkMode_(*lpdis\hDC, #TRANSPARENT)
        FillRect_(*lpdis\hDC, *lpdis\rcItem, *osbt\hBrush) 
        DrawText_(*lpdis\hDC, *osbt\szText, -1, *lpdis\rcItem, #DT_SINGLELINE | #DT_VCENTER | #DT_RIGHT)
      EndIf
  EndSelect
 
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure myStatusBarText(Field, Text.s, fCol, bCol)
  Text+"   "
  osbt(Field)\szText = Text
  osbt(Field)\clrFront = fCol
  osbt(Field)\hBrush  = CreateSolidBrush_(bCol)
  SendMessage_(Result,#SB_SETTEXT, Field | #SBT_OWNERDRAW, osbt(Field))
EndProcedure

OpenWindow(0,0,0,350,100,"Custom Statusbar Text Colors",#WS_OVERLAPPEDWINDOW | 1)

SetWindowCallback(@WindowCallback())

Result = CreateStatusBar(0,WindowID(0))

AddStatusBarField(100)
AddStatusBarField(100)
AddStatusBarField(900)

SendMessage_(Result, #SB_SETMINHEIGHT, 40, 0)
SendMessage_(Result, #WM_SIZE, 0,0)

Text.s="1"
Field=0
fCol.l=#Green
bCol.l=#Gray
myStatusBarText(Field, Text, fCol, bCol)

Text.s="2"
Field=1
fCol.l=#Yellow
bCol.l=#Blue
myStatusBarText(Field, Text, fCol, bCol)

Text.s="3"
Field=2
fCol.l=#Red
bCol.l=#Yellow
myStatusBarText(Field, Text, fCol, bCol)


While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Image Image
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: StatusBar background color.

Post by dibor »

Tnx davido and Paul!
Will try to use Thorsten module because I do not understand windows API at all.

Best Wishes!
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: StatusBar background color.

Post by skywalk »

dibor wrote: Sat Jul 17, 2021 7:10 pm Tnx for answer.
ts-soft ???
Maybe mk-soft?
Anyway, do not find any example :(
Give me link if U have.

Thank U
ts-soft container as statusbar
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: StatusBar background color.

Post by dibor »

Hello.
Thorsten Hoeppner module looks good and has many options.
His example also runs as should, but when I try to implement this module in my program - I got status bar but in wrong location.
Looks like wrong window size determination, only with statusbar height 48 I can see text.
Image

Will try to understand where and what I did wrong.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: StatusBar background color.

Post by dibor »

Looks like this too complicate for me. :(
I do not understand where the problem. :(
In the windows module works wrong
Image


But in the Mac - looks GOOD
Image
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Post Reply