 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
rob kemp Guest
|
Posted: Wed May 16, 2007 8:08 am Post subject: Copy the content from one RichEdit to another while maintain |
|
|
I have two RichEdit components (RichEdit1 and RichEdit3) where
RichEdit1 is filled with new rich text (fonts, alignments, colors, etc.) many times during run time (cleared and then new content is added)
a) I need to collect (add to existing text already in RichEdit3
and NOT clear whatever is out there) the content of RichEdit1
into RichEdit3 while maintaining the fonts/colors/alignments/etc.
I tried to execute this code everytime I get a new content in RichEdit1 but I lose the fonts/colors/aligments, etc.
//execute this code to add content in RE1 to RE3
for(int x = 0; x <linesinRE1; x++)
{
RichEdit3->Lines->Add(RichEdit1->Lines->Strings[x]);
}
b) is there a way to add a page break into Richedit3 evertime I
add a new content from RichEdit1, so each new content will be
on a seperate page when RichEdit3 is saved and opened by MS Word
Your help will be greatly appreciated
Rob |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed May 16, 2007 9:46 pm Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
"rob kemp" <nospam (AT) thanks (DOT) com> wrote in message
news:464a75cb$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I need to collect (add to existing text already in RichEdit3
and NOT clear whatever is out there) the content of RichEdit1
into RichEdit3 while maintaining the fonts/colors/alignments/etc.
|
Then you can't use the Lines property at all. As you have already
noticed, it loses the formatting. You will need to use the
EM_STREAMIN/OUT messages directly instead. For example:
#include <memory>
DWORD CALLBACK StreamOutCallback(DWORD dwCookie, LPBYTE pbBuff,
LONG cb, LONG FAR *pcb)
{
*pcb =
reinterpret_cast<TMemoryStream*>(dwCookie)->Write(pbBuff, cb);
return 0;
}
DWORD CALLBACK StreamInCallback(DWORD dwCookie, LPBYTE pbBuff,
LONG cb, LONG FAR *pcb)
{
*pcb =
reinterpret_cast<TMemoryStream*>(dwCookie)->Read(pbBuff, cb);
return 0;
}
{
std::auto_ptr<TMemoryStream> data(new TMemoryStream);
EDITSTREAM s;
s.dwCookie = reinterpret_cast<DWORD>(data.get());
s.dwError = 0;
s.pfnCallback = StreamOutCallback;
RichEdit1->Perform(EM_STREAMOUT, SF_RTF,
reinterpret_cast<int>(&s));
if( s.dwError != 0 )
{
// an error occured...
return;
}
data->Position = 0;
s.dwError = 0;
s.pfnCallback = StreamInCallback;
RichEdit1->SelStart = RichEdit1->GetTextLen();
RichEdit1->SelLength = 0;
RichEdit3->Perform(EM_STREAMIN, SF_RTF | SFF_SELECTION,
reinterpret_cast<int>(&s));
}
| Quote: | is there a way to add a page break into Richedit3 evertime I add
a new content from RichEdit1, so each new content will be on a
seperate page when RichEdit3 is saved and opened by MS Word
|
Since EM_STREAMIN/OUT messages work with the underlying RTF codes, you
could manually insert a page break instruction into the data before
loading it into the target RichEdit.
Gambit |
|
| Back to top |
|
 |
rob kemp Guest
|
Posted: Wed May 16, 2007 11:10 pm Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
Thanks Remi
Per your reply, how can I insert the page breaks manually? is it by adding \p or <Page Break>?
is this is the right syntax?
thanks in advance
Rob
| Quote: | Since EM_STREAMIN/OUT messages work with the underlying RTF >codes, you
could manually insert a page break instruction into the data >before
loading it into the target RichEdit. |
|
|
| Back to top |
|
 |
rob kemp Guest
|
Posted: Wed May 16, 2007 11:10 pm Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
Thanks Remi
Per your reply, how can I insert the page breaks manually? is it by adding \p or <Page Break>?
is this is the right syntax?
thanks in advance
Rob
| Quote: | Since EM_STREAMIN/OUT messages work with the underlying RTF >codes, you
could manually insert a page break instruction into the data >before
loading it into the target RichEdit. |
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu May 17, 2007 12:02 am Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
"rob kemp" <nospam (AT) thanks (DOT) com> wrote in message
news:464b491b$3 (AT) newsgroups (DOT) borland.com...
| Quote: | Per your reply, how can I insert the page breaks manually?
|
I suggest you read up on how RTF works in general.
Gambit |
|
| Back to top |
|
 |
rob kemp Guest
|
Posted: Thu May 17, 2007 2:12 am Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
I read about RFT and googled a lot.
And quite honestly I got confused with posts indicating that page breaks are supported in some of the RTF releases and not in others....
I really need help on this!
I guess it's pretty simple what i need to do but can't figure out how to do it
RichEdit1->Lines->Add("This line is on page1");
RichEdit1->Lines->Add("This line is on a new page");
RichEdit1->Lines->Add("This line is on a new page");
//etc.
RichEdit1->Lines->SaveToFile( "C:\\test.rtf");
I need to add a page break between the lines so when the user
open the saved test.rtf file with ShellExecute he sees the each line on a different page
Thanks in advance for your help on this
Rob |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu May 17, 2007 3:16 am Post subject: Re: Copy the content from one RichEdit to another while main |
|
|
"rob kemp" <nospam (AT) thanks (DOT) com> wrote in message
news:464b73c0$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I read about RFT and googled a lot.
And quite honestly I got confused with posts indicating
that page breaks are supported in some of the RTF
releases and not in others....
|
If you read the RTF specification on Microsoft's website, you will see
the codes for page breaks. If you create a document in MS Word and
then save it in RTF format, you can see the codes it uses for page
breaks.
| Quote: | I guess it's pretty simple what i need to do but can't figure
out how to do it
|
There is nothing available in the VCL to insert page breaks. You have
to do it manually at the RTF level.
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|