Board index » cppbuilder » Stroring RTFtext into AnsiString

Stroring RTFtext into AnsiString


2004-06-04 06:09:22 PM
cppbuilder113
I need to strore RTF text at run time into a variable like this:
RichEdit1->PasteFromClipboard();
AnsiString sBuffer=RichEdit1->Lines->Text;
But the result is that, sBuffer contains ANSI text not RTF text. Why could I
do ?
Sam
 
 

Re:Stroring RTFtext into AnsiString

"Sam" < XXXX@XXXXX.COM >wrote:
Quote
[...] But the result is that, sBuffer contains ANSI text not
RTF text.
RTF-encoded text can be retrieved from a Rich Edit control
using WinAPI calls. This link might shed some light:
www.geocities.com/rodolfofrino/ExtendedRichEdit.html
If you're going to be using TRichEdit's to any extent, this
site is good place to look over:
home.att.net/~robertdunn/Yacs.html
~ JD
 

Re:Stroring RTFtext into AnsiString

JD wrote:
Quote
RTF-encoded text can be retrieved from a Rich Edit control
using WinAPI calls. This link might shed some light:

www.geocities.com/rodolfofrino/ExtendedRichEdit.html
Apart from a nearly unreadable page ( black font on blue background );
I have no idea what kind of light it should shed.
Hans.
 

{smallsort}

Re:Stroring RTFtext into AnsiString

Hans Galema < XXXX@XXXXX.COM >wrote:
Quote
JD wrote:

>RTF-encoded text can be retrieved from a Rich Edit control
>using WinAPI calls. This link might shed some light:
>
>www.geocities.com/rodolfofrino/ExtendedRichEdit.html

Apart from a nearly unreadable page [...]
Yeah I hate it too.
Quote
I have no idea what kind of light it should shed.
Seems that I bookmarked the wrong page. He's got one in there
somewhere that lists all of the (useful) win32 API's.
~ JD
 

Re:Stroring RTFtext into AnsiString

Sam wrote:
Quote
I need to strore RTF text at run time into a variable like this:
RichEdit1->PasteFromClipboard();
AnsiString sBuffer=RichEdit1->Lines->Text;

But the result is that, sBuffer contains ANSI text not RTF text. Why could I
do ?
What would you do with those variables? You cannot add them as
every variable will contain a complete rtf document (if you succeeded).
A simple solution would be to let the TRichEdit save its contents in
a .rtf file. Then load the file in a TStringList and assign its Text
to the AnsiString.
RichEdit1->PasteFromClipboard();
AnsiString FileName = "content.rtf";
RichEdit1->Lines->SaveToFile ( FileName );
// create a TStingList
StringList->LoadFromFile ( FileName );
AnsiString asBuffer = StringList->Text;
// delete the StringList
ShowMessage ( asBuffer );
A nicer solution would be to stream the contents of the
TRichEdit out.
Hans.
 

Re:Stroring RTFtext into AnsiString

"Sam" < XXXX@XXXXX.COM >wrote in message
Quote
But the result is that, sBuffer contains ANSI text not RTF text.
As well it should be, because that is how the Text property works. To get
the original RTF, set the RichEdit's PlainText property to false and then
use its SaveToStream() method, such as to a TStringStream. You can then
extract an AnsiString from that.
Gambit