Get statusbar text

Just starting out? Need help? Post your questions and find answers here.
mx101
User
User
Posts: 73
Joined: Thu Sep 18, 2008 3:21 pm

Get statusbar text

Post by mx101 »

hi...

If someone can help me with one example.


How can i get text of statusbar?


sorry for my english
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Get statusbar text

Post by IdeasVacuum »

Well, if you mean the status bar text from the window of your own program, you should not need to collect it, since your app should already have the value held in a variable.......
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Get statusbar text

Post by Fangbeast »

mx101 wrote:hi...

If someone can help me with one example.


How can i get text of statusbar?


sorry for my english
Had to delete all the other posts, my very crappy coding. The below is a lot nicer to read

Code: Select all

;==========================================================================================================================
; Get the text from a specified statusbar and field in that statusbar
;==========================================================================================================================

Procedure.s GetStatusBarText(StatusbarNumber, FieldNumber)
  
  ; Find the length of the text to get from the specified statusbar (last parameter has to be 0)
  
  StringBufferLength = SendMessage_(StatusBarID(StatusbarNumber), #SB_GETTEXTLENGTH, FieldNumber, 0)
  
  ; Proceed only if we managed to get the length of the characters to retrieve
  
  If StringBufferLength
    
    ; Just tell the user how many characters we are going to try to get back
    
    Debug "String length to get is: " + Str(StringBufferLength)
    
    ; Create an empty string that is the length of the characters we are going to try to get back
    
    StringBuffer.s = Space(Length)
    
    ; Now try to get the characters back from the statusbar in the specified field into the string buffer
    
    SendMessage_(StatusBarID(StatusbarNumber), #SB_GETTEXT, FieldNumber, @BufferString)
    
    ; Only proceed if we got any characters back
    
    If StringBuffer.s
      
      ProcedureReturn PeekS(@BufferString)
      
    Else ; Return an empty string as nothing was retrieved despite the buffer length being initialised
      
      ProcedureReturn ""
      
    EndIf
    
    ; 
    
  Else
    
    ProcedureReturn "There are no characters to be retrieved"
    
  EndIf
  
  ; 
  
EndProcedure

; Test this procedure with any program

Debug GetStatusBarText(1, 2)   ; Get the text from field 2 in statusbar 1 (use constants, much better)

Last edited by Fangbeast on Mon Mar 28, 2011 9:01 pm, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
mx101
User
User
Posts: 73
Joined: Thu Sep 18, 2008 3:21 pm

Re: Get statusbar text

Post by mx101 »

Fangbeast wrote:
mx101 wrote:hi...

If someone can help me with one example.


How can i get text of statusbar?


sorry for my english
Had to delete all the other posts, my very crappy coding. The below is a lot nicer to read

Code: Select all

;==========================================================================================================================
; Get the text from a specified statusbar and field in that statusbar
;==========================================================================================================================

Procedure.s GetStatusBarText(StatusbarNumber, FieldNumber)
  
  ; Find the length of the text to get from the specified statusbar (last parameter has to be 0)
  
  StringBufferLength = SendMessage_(StatusBarID(StatusbarNumber), #SB_GETTEXTLENGTH, FieldNumber, 0)
  
  ; Proceed only if we managed to get the length of the characters to retrieve
  
  If StringBufferLength
    
    ; Just tell the user how many characters we are going to try to get back
    
    Debug "String length to get is: " + Str(StringBufferLength)
    
    ; Create an empty string that is the length of the characters we are going to try to get back
    
    StringBuffer.s = Space(Length)
    
    ; Now try to get the characters back from the statusbar int he specified field into the string buffer
    
    SendMessage_(StatusBarID(StatusbarNumber), #SB_GETTEXT, FieldNumber, @BufferString)
    
    ; Only proceed if we got any characters back
    
    If StringBuffer.s
      
      ProcedureReturn PeekS(@BufferString)
      
    Else ; Return an empty string as nothing was retrieved despite the buffer length being initialised
      
      ProcedureReturn ""
      
    EndIf
    
    ; 
    
  Else
    
    ProcedureReturn "There are no characters to be retrieved"
    
  EndIf
  
  ; 
  
EndProcedure

; Test this procedure with any program

Debug GetStatusBarText(1, 2)   ; Get the text from field 2 in statusbar 1 (use constants, much better)

hi...

thank you work great. :D
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Get statusbar text

Post by Fangbeast »

hi...

thank you work great. :D
My pleasure. I got something right in 9 years :D :D :D :D
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply