PDA

View Full Version : Textbox Limit?



catventure
16-11-2006, 14:21
Hi,

Is there a limit to the amount of text that a textbox control can hold?
I was pasting a 1000 line ascii textfile of adventure text into a textbox control in my TAB program and it didn't all copy across...
If so, can the limit be extended to cope with larger files?
Thanks.

Added: Well it seems the default value of a MaxLength property of a textbox is 32767. After that it just stops reading characters... Forgot about that.
That would not be suitable for larger adventure game data in my program - but I think I can get round it using a RTF Richedit control instead, I think... Will try it and see :)

catventure.

RobertoBianchi
16-11-2006, 15:42
Hi Catventure,

try to send the following message:


SendMessage hEdit, %EM_SETLIMITTEXT, 0, 0

that in a edit controls on Windows 95/98/Me: the text length is set to 32766 characters for single-line edit controls or 65535 for multiline edit controls.
Of course, if you need more than 32766 characters you should create an edit box (aka a window) with %ES_MULTILINE style.
Better as you said, is switch to use a richedit control and then use %EM_EXLIMITTEXT message to set the limit upper the default 64K characters size.

Ciao,
Roberto

catventure
16-11-2006, 17:09
Hi Roberto,

Using richedit with a higher text limit works OK with a file now double the size of the large file I was using! :)



CONTROL ADD rtf_GetClass, hdlg, 620, "", 125, 15, 260, 240, _
%WS_CHILD OR %WS_CLIPCHILDREN or %WS_VISIBLE OR %ES_MULTILINE OR _
%WS_VSCROLL,%WS_EX_CLIENTEDGE

control send hDlg, 620, %EM_LIMITTEXT, 1400000, 0

CONTROL SEND hDlg, 620, %EM_SETBKGNDCOLOR, 0, rgb(0,0,0)
RTF_SETFGCOLOR (hdlg,620,rgb(255,255,255))



However in my investigations I have come across possible bug:

RTF_SaveToFile(hdlg, ctrlID, filename, %sf_text)

works great whilst

RTF_LoadFromFile(hdlg, ctrlID, filename, %sf_text)

does not work...

Neither does it work with "richedit002.tbasic" example in SampleScripts\UI\Richedit with a lot lot smaller text files.

I think it due to "%sf_text" problem as rtf type files loads OK.

Regards,
catventure

catventure
16-11-2006, 18:36
Hi,
Just to let you know...
I have managed to get the "text" file loading into and saving from the richedit control *perfectly* using following code where 'sFile' is the filepath

tempstr=rtf_gettext(hdlg,620,%sf_text)
file_save(sFile,tempstr)
'---file is saved OK from richedit

response=file_load(sFile)
rtf_appendtext(hdlg,620,response)
'---file is loaded OK to richedit

I will use this until mystery with RTF_SAVETOFILE and RTF_LOADFROMFILE is discovered.

catventure.

Petr Schreiber
17-11-2006, 19:00
Hi catventure,

I presume you are tuning this on TAB.
Do you have handled case when player is playing the game so long that the text limit is reached ?

Bye,
Petr

catventure
17-11-2006, 19:07
Hi Petr,

OOerr. Good thought, Petr. No I haven't got that check in place yet.
Will look at that though.
I'm converting a text adventure game to use in the program, and its fairly large so it will be a good test for the adventure builder.

catventure

Petr Schreiber
17-11-2006, 19:14
Hmm,

new large game for TAB ? Perfect, long winter evenings are approaching, good to have game to play :)


Thanks,
Petr

ErosOlmi
18-11-2006, 14:36
Catventure,

RTF_LoadFromFile and RTF_SaveToFile had bugs now fixed.
Next release quite ready.

Eros

catventure
18-11-2006, 19:15
Great!
Thanks very much for the quick fix and inclusion into stable verison 1.1.0.0

Cheers,
catventure.