Page 1 of 1

The Upper limit of GetWindowText_()

Posted: Wed Jun 04, 2003 11:20 am
by cecilcheah
Hi all

How big can the third parameter be in the GetWindowText_(,,) function? I search the forum and see someonme uses 10000, but what is the upper limit?

What happen if the window text is more than the upper limit, how can i retrieve all the text then?

Thanks

Cecil

Posted: Wed Jun 04, 2003 12:32 pm
by freak
There should be no upper limit to that function.
The only limit you will run into is PB's limit of the String size (max 64K)

However, if you use a memorybuffer instead of a PB string, it should be unlimited.

Timo

Posted: Wed Jun 04, 2003 12:54 pm
by cecilcheah
Hi there

Can you give me an example of how to use a memorybuffer in the GetWindowText_().

I am new to this Pure Basic and am just searching for PB codes to learn the stuff

hanks in advance

Cecil

Posted: Wed Jun 04, 2003 12:56 pm
by LarsG
The question is: why would you want a windowtext with more than 65536 characters..)) hehe ;)

Posted: Wed Jun 04, 2003 12:59 pm
by cecilcheah
Good question.

The reason is i am not getting the window title text, but say the text in the text field itself.

For example
So instead of getting the "Untitled - Notepad", i am getting the text in the note pad.

Cecil

Posted: Wed Jun 04, 2003 1:05 pm
by LarsG
aaahh.. ok... my bad... :roll:

Posted: Wed Jun 04, 2003 1:06 pm
by Saboteur
You can do it with pointers:

Code: Select all

If OpenWindow(0, 100,100,300,300,#PB_Window_SystemMenu,"Hello")
  If CreateGadgetList(WindowID())
    StringGadget(0,10,10,200,20,"this is a demo")
  EndIf

  *buffer=AllocateMemory(0,100000)
  GetWindowText_(GadgetID(0),*buffer,100000)
  
  MessageRequester("result",PeekS(*buffer),0)
  
  FreeMemory(0)
EndIf

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
End
Try it with a long text... :wink:

Posted: Wed Jun 04, 2003 1:13 pm
by cecilcheah
Thanks a lot. Really appreciate your quick response.

Cecil

Posted: Wed Jun 04, 2003 1:37 pm
by GedB
You can also use the GetWindowTextLength_() function to find out the size of the buffer needed:

Code: Select all

If OpenWindow(0, 100,100,300,300,#PB_Window_SystemMenu,"Hello") 
  If CreateGadgetList(WindowID()) 
    StringGadget(0,10,10,200,20,"This is text") 
  EndIf 
    bufferSize=GetWindowTextLength_(GadgetID(0))+1
  If bufferSize > 0
      *buffer=AllocateMemory(0,bufferSize) 
    GetWindowText_(GadgetID(0),*buffer,bufferSize) 
    
    MessageRequester("result",PeekS(*buffer, bufferSize),0) 
    
    FreeMemory(0) 
    Else
        MessageRequester("result","",0) 
    EndIf
EndIf 

Repeat 
Until WaitWindowEvent()=#PB_Event_CloseWindow 
End 

Posted: Wed Jun 04, 2003 2:13 pm
by cecilcheah
Thanks a lot. This is a good idea to do, so my programme will not take up too much resources.

thanks

Cecil