Does a statusbar segment have an own handle?

Just starting out? Need help? Post your questions and find answers here.
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Does a statusbar segment have an own handle?

Post by jacdelad »

The title says it. Does it? If so, how can I retrieve it? I know Windows provides statusbars with text and icons, but PB also has progressbars, so there must be something more. And I don't want to use a canvas.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Does a statusbar segment have an own handle?

Post by spikey »

They don't appear to have and I can't really think of any reason why this would be neccessary to implement the status bar's own functionality. Text, separators and images are static so can be drawn directly in the same context as the bar's own features. When you add a progress bar this gets added as a child control.
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Does a statusbar segment have an own handle?

Post by jacdelad »

Thanks for the answer. My intention is very obvious (at least I thought so): putting a different control into a segment, like a combobox, checkbox, etc.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Does a statusbar segment have an own handle?

Post by firace »

Check out the below example ;)
Edit: height fixed

Code: Select all


OpenWindow(0,#PB_Ignore,0,420,100,"Status Test", #PB_Window_SizeGadget | #PB_Window_SystemMenu)

hstatus = CreateStatusBar(#PB_Any, WindowID(0))
SendMessage_(StatusBarID(hstatus), #SB_SETMINHEIGHT, 29, 0)   ;;; thanks rashad!
SendMessage_(StatusBarID(hstatus), #WM_SIZE, 0,0)
AddStatusBarField(450)

Cont_1 = ContainerGadget(#PB_Any, 100, 1, 392, 25)
x = StringGadget(#PB_Any, 1, 3,100, 22, "HALLO")
y = ComboBoxGadget(#PB_Any, 200, 3,100, 22)
AddGadgetItem(y, -1, "Choose item")
AddGadgetItem(y, -1, "Item 1")
AddGadgetItem(y, -1, "Item 2")
SetGadgetState(y, 0)
SetGadgetColor(x, #PB_Gadget_FrontColor,#Red)   

SetParent_(GadgetID(Cont_1),StatusBarID(hstatus))


Repeat : Until WaitWindowEvent() = 13116

User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Does a statusbar segment have an own handle?

Post by jacdelad »

Firstly, thanks very much.

But this is not exactly what I'm looking for. The statusbar is not segmented. I know, I can simulate segments by myself, but this is not exactly what I wanted.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Does a statusbar segment have an own handle?

Post by RASHAD »

Hi
No Handle for the StatusBar Field
But you can work around
Open the GadgetList() at any time then add,delete any PB gadget as usual then close the list

Code: Select all


If OpenWindow(0, 0, 0, 600, 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(250)
  AddStatusBarField(120)
  AddStatusBarField(120)
  
  UseGadgetList(StatusBarID(0))
  
  ContainerGadget(0,1,1,248,38)
  CloseGadgetList()
  
  ContainerGadget(1,250,1,118,38)
  CloseGadgetList()  
  ;   
  ContainerGadget(2,370,1,118,38)
  CloseGadgetList()
  
  OpenGadgetList(0)
  CheckBoxGadget(#PB_Any,5,5,60,28,"TEST")
  comb0 = ComboBoxGadget(#PB_Any,70,5,170,28)
  For a = 1 To 5
    AddGadgetItem(comb0, -1,"ComboBox item " + Str(a))
  Next
  SetGadgetState(comb0,2)
  CloseGadgetList()
  
  OpenGadgetList(2)
  butt2 = ButtonGadget(#PB_Any,5,5,60,28,"RUN")
  CloseGadgetList()
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
    EndSelect        
    
  Until Quit = 1
  
EndIf 

Egypt my love
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Does a statusbar segment have an own handle?

Post by Paul »

Nice code RASHAD!
Just a note, if you're using a 4K monitor with scaling set and compile with "DPI aware ON" you need to make a slight change for things to look right...

Code: Select all

  dpiaware.d=DesktopResolutionX()
  CreateStatusBar(0, WindowID(0))  
  SendMessage_(StatusBarID(0), #SB_SETMINHEIGHT, 38*dpiaware, 0)
  SendMessage_(StatusBarID(0), #WM_SIZE, 0,0)
  AddStatusBarField(250*dpiaware)
  AddStatusBarField(120*dpiaware)
  AddStatusBarField(120*dpiaware)
Image Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Does a statusbar segment have an own handle?

Post by RASHAD »

Hi Paul
Thanks for your contribution
Amazing :)
It seem with Windows 11 everything goes well with or without DPI aware
Can anyone agree if that is true or correct ?
Egypt my love
User avatar
jacdelad
Addict
Addict
Posts: 1432
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Does a statusbar segment have an own handle?

Post by jacdelad »

Thanks RASHAD and Paul. This is very creative, but still not what I was asking for. As mentioned the statusbar elements don't have an own handle, so I have to stick with that. No problem at all.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
fryquez
Enthusiast
Enthusiast
Posts: 362
Joined: Mon Dec 21, 2015 8:12 pm

Re: Does a statusbar segment have an own handle?

Post by fryquez »

RASHAD wrote: Wed Jul 21, 2021 5:10 am It seem with Windows 11 everything goes well with or without DPI aware
Can anyone agree if that is true or correct ?
No, it the same as in Windows 10.

The SendMessage_() needs the dpi factor set.

AddStatusBarField() should actually apply dpi factor internally, but does not. PB Bug!


As for the question: statusbar elements don't have any handle.
Post Reply