I have a RichEdit control that I want to load by adding the data from a large RTF file into the control. The RTF file is 337KB I read the whole file into a string buffer and the use a FF function to set the text into the RichEdit control. The problem is that the FF function fails to load the complete string into the control.
Is there a size limit to the string that FF_TextBox_SetText can handle?
It behaves as though it is truncating the string.
Is there a way to load large strings into the RichEdit control?
This is the method I am using:
Local buf As String
Open "LargeFile.rtf" For Binary As #1
buf = Space$(Lof(1))
Get #1, 1, buf
Close #1
FF_TextBox_SetText (HWND_Form1_RICHEDIT1, buf )
http://msdn.microsoft.com/en-us/library/bb787877(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/bb787877(v=vs.85).aspx)
It says there:
Quote...However, a rich edit control will never contain more than 32K characters of text, unless you extend this limit by using the EM_LIMITTEXT or EM_EXLIMITTEXT message.
You might want to check this thread too:
http://www.powerbasic.com/support/pbforums/showthread.php?t=40720&highlight=richedit+limit (http://www.powerbasic.com/support/pbforums/showthread.php?t=40720&highlight=richedit+limit)
Thanks Rolf. Chris Boss also suggested this.
Quote
The best (and proper IMO) way to set and get text with a RichEdit control is to use the following messages:
EM_STREAMIN
EM_STREAMOUT
These commands allow you to move very large blocks of text (in the megabytes), to move only selected portions of the text (what is selected or highlighted) and to move text in either ascii or RTF (RichText Format).
I think the best place for this to be done would be in the
FF_TextBox_SetText function, since it's the FF function that is failing to load the RichEdit control. Am I wrong? Is there some other place that this problem should be fixed?
I'm thinking that the
FF_TextBox_SetText function could be testing for the size of the string being passed by it to the RichEdit control and if the string is larger than normally allowed then the FF function would do what ever it needs to do to load the whole string. Possibly using the EM_StreamIn or EM_StreamOut methods.
Am I wrong? Should the problem be solved in another way?
Maybe try using the FF_RichEdit_SetText function rather than the FF_TextBox_SetText....
:P :P :P
Paul,
I gave that a try. Using:
FF_RichEdit_SetText (HWND_Form1_RICHEDIT1, buf, 0 )
But to my dismay, I find that it had the same results only loaded part of the string.
:'(
Have you given it a try with a large RTF file?
One note that might help you. If set the string in the field as pure text using parameter 1 then the whole string is set into the field but is NOT formated with the RTF characters. The rtf characters show up as text.
If you are using my headers, try RichEdit_SetRtfText.
Include "RichEditCtrl.inc".
Hi Jose - using your code didn't seem to help - sorry. Looks like the code is being cut around 64K.... not sure, I'm investigating.
For the RichEdit control set the "MaxLength" property to -1 rather than 0 and it will display the whole file.
Thanks Pauls. Superb support. Thank you.
Whoda known such a simply solution.
...Marty