How do I get id of a statusbartext?

Just starting out? Need help? Post your questions and find answers here.
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

How do I get id of a statusbartext?

Post by garretthylltun »

I tried a search but found nothing, or I didn't search for the right terms.

I would like to disable/enable specific StatusBarText items, but either it's not possible or I'm doing it wrong. I've tried doing the following to get the id:

Code: Select all

StatusText1.s=GadgetID(StatusBarText(0,1))
Any pointers appreciated.

Thanks,
~Garrett
'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
User avatar
skywalk
Addict
Addict
Posts: 4316
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How do I get id of a statusbartext?

Post by skywalk »

The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: How do I get id of a statusbartext?

Post by Shardik »

For Windows this code example demonstrates how to display a StatusBarField as seemingly disabled.

The following code example (Windows only) demonstrates how to change the text of a StatusBarField:

Code: Select all

OpenWindow(0, 200, 100, 300, 80, "StatusBar demo")
ButtonGadget(0, 55, 20, 180, 20, "Change text in 2nd StatusBarField")

If CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  AddStatusBarField(100)
  AddStatusBarField(#PB_Ignore)
EndIf

StatusBarText(0, 0, "Info 1")
StatusBarText(0, 1, "Info 2")
StatusBarText(0, 2, "Info 3") 

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
        SendMessage_(StatusBarID(0), #SB_SETTEXT, 1, @"Info 2 changed!")
        DisableGadget(0, #True)
      EndIf
  EndSelect
ForEver
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: How do I get id of a statusbartext?

Post by em_uk »

Why didn't you just check the help? It's right there.

The PB team have spent a great deal of time making it as complete as can be so use it! ;)
----

R Tape loading error, 0:1
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: How do I get id of a statusbartext?

Post by Shardik »

skywalk wrote:StatusBar Manual...
em_uk wrote:Why didn't you just check the help? It's right there.

The PB team have spent a great deal of time making it as complete as can be so use it! ;)
Sorry, but where does the StatusBar help describe how to solve the problem of the original poster: to disable or enable a StatusBarField containing text (this is only possible with a callback using API functions or as an alternative demonstrated by RASHAD with overdrawing the text in the StatusBarField using graphics functions) or how to get the ID of a StatusBarField containing text (not the ID of the StatusBar)? It's only possible to read/change the text of a StatusBarField by using API funktions, hence my code example... :wink:
Last edited by Shardik on Wed Jan 08, 2014 1:12 pm, edited 1 time in total.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: How do I get id of a statusbartext?

Post by PB »

> where does the StatusBar help describe how to solve
> the problem of the original poster

They're replying to the topic's subject: "How do I get ID..." ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Demivec
Addict
Addict
Posts: 4283
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: How do I get id of a statusbartext?

Post by Demivec »

Shardik wrote:It's only possible to read/change the text of a StatusBarField by using API funktions, hence my code example... :wink:
Here's your example code that has been changed so it should be cross-platform, without using API functions, by following the information from the Manual for StatusBar. :wink:

Code: Select all

OpenWindow(0, 200, 100, 300, 80, "StatusBar demo")
ButtonGadget(0, 55, 20, 180, 20, "Change text in 2nd StatusBarField")

If CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  AddStatusBarField(100)
  AddStatusBarField(#PB_Ignore)
EndIf

StatusBarText(0, 0, "Info 1")
StatusBarText(0, 1, "Info 2")
StatusBarText(0, 2, "Info 3") 

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
        StatusBarText(0, 1, "Info 2 changed!")
        DisableGadget(0, #True)
      EndIf
  EndSelect
ForEver
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: How do I get id of a statusbartext?

Post by Shardik »

Demivec wrote:Here's your example code that has been changed so it should be cross-platform, without using API functions, by following the information from the Manual for StatusBar. :wink:
Thank you for opening my eyes, Demivec... :oops:
I simply didn't understand that it's possible to change the text of a StatusBarField. I thought that it's only possible to define the text once...

Now please also show me how to disable the text of a StatusBarField according to the manual... :twisted:
User avatar
Demivec
Addict
Addict
Posts: 4283
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: How do I get id of a statusbartext?

Post by Demivec »

Shardik wrote:Now please also show me how to disable the text of a StatusBarField according to the manual... :twisted:
Status bars become disabled when you don't update them anymore. As RASHAD showed you can simply replace a text field with an image showing whatever you want, in his example it was gray text.

IMHO the limitation is on determining the colors for an OS that indicate something is disabled. This is not a limitation on the functionality of the StatusBar in PureBasic. :wink:
User avatar
skywalk
Addict
Addict
Posts: 4316
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How do I get id of a statusbartext?

Post by skywalk »

Shardik wrote:I simply didn't understand that it's possible to change the text of a StatusBarField. I thought that it's only possible to define the text once...
It is called a StatusBarField so you can update it more than once. :wink:
But, I do have to use a callback and api calls to respond to user MouseClicks.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Re: How do I get id of a statusbartext?

Post by garretthylltun »

I do apologize if I caused any confusion or failed to find the info on my own.

I thought I could use DisableGadget() if I had the ID of the specific field in the StatusBar. But I was unable to find anything in the Help File or via search here on the forums. I saw StatusBarID() but that only gets me the ID of the StatusBar and not any individual field within the StatusBar.

My goal was to set 1 of 3 fields to disable or enabled based on CAPS, NUM and SCROLL for a little notes program. Typically these are in the status bar and are either Enabled or Disabled based on whether those keys are active or inactive.

I do not see in the help file where I can get the ID of any StatusBarText, only the StatusBar... If I am missing something, could someone please tell me what in the help file explains this to me?

And to those who say that the PB team has better things to do... What is the point of the forums then? I thought the forums were here for users to get help from one another, am I incorrect? Did I post this in the wrong section? If so, I do apologize.

P.S. I spent near 2 hours trying to figure this out, searching the help file, trying various keywords and keyword combinations on the search of the forums. I might be old and absent minded at times but I am not an idiot.. I just could not find the answers.
'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
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Re: How do I get id of a statusbartext?

Post by garretthylltun »

Thank you Shardik.. That may be exactly what I was looking for.

It's obvious now that what I was looking for is not a built-in feature and someone had to come up with a work-around... So, The help file would not have specifically helped. I'd like to see someone try to find this answer under "StatusBar Manual..."

Thanks to those who offered help. It really is appreciated,
~Garrett


Could a Mod plz move this thread to it's appropriate section. Thx
'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