The Upper limit of GetWindowText_()
-
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland
The Upper limit of GetWindowText_()
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
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
-
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland
The question is: why would you want a windowtext with more than 65536 characters..)) hehe 
AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
-
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland
You can do it with pointers:
Try it with a long text... 
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
[:: PB Registered ::]
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
-
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland
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 -
cecilcheah
- Enthusiast

- Posts: 168
- Joined: Wed Jun 04, 2003 8:44 am
- Location: Switzerland

