BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding formatted text programmatically

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Brian
Guest





PostPosted: Sun May 06, 2007 4:20 am    Post subject: Adding formatted text programmatically Reply with quote



I need to add formatted text to a TRichEdit (or a TJvRichEdit if that
works better). I am trying things along the following lines, with no
luck:

TFont* boldFont = new TFont();
boldFont->Style << fsBold;
JvRichEdit->AddFormatText("This should be bold\n",boldFont);
TFont* normFont = new TFont();
JvRichEdit->AddFormatText("This should be normal\n",normFont);
JvRichEdit->AddFormatText("\nnow This should be
bold",TFontStyles(fsBold));
JvRichEdit->AddFormatText("\nnow This should be
normal",TFontStyles());


RichEdit->Font->Style = Errors->Font->Style << fsBold;
RichEdit->DefAttributes->Style << fsBold;
RichEdit->Lines->Add("This should be bold\n");
RichEdit->Font->Style = Errors->Font->Style >> fsBold;
RichEdit->DefAttributes->Style >> fsBold;
RichEdit->Lines->Add("This should be normal\n");

Could someone please give me some quick pointers for either control?
I'm having a hard time finding documentation or examples. I'm using
BDS 2006 C++ Builder Personality.

Thanks
Back to top
Antonio Felix
Guest





PostPosted: Sun May 06, 2007 5:47 am    Post subject: Re: Adding formatted text programmatically Reply with quote



"Brian" <bvanmatre (AT) yahoo (DOT) com> escreveu na mensagem
news:1178407240.314126.312730 (AT) e65g2000hsc (DOT) googlegroups.com...
Quote:
I need to add formatted text to a TRichEdit (or a TJvRichEdit if that
works better). I am trying things along the following lines, with no
luck:

TFont* boldFont = new TFont();
boldFont->Style << fsBold;
JvRichEdit->AddFormatText("This should be bold\n",boldFont);
TFont* normFont = new TFont();
JvRichEdit->AddFormatText("This should be normal\n",normFont);
JvRichEdit->AddFormatText("\nnow This should be
bold",TFontStyles(fsBold));
JvRichEdit->AddFormatText("\nnow This should be
normal",TFontStyles());


RichEdit->Font->Style = Errors->Font->Style << fsBold;
RichEdit->DefAttributes->Style << fsBold;
RichEdit->Lines->Add("This should be bold\n");
RichEdit->Font->Style = Errors->Font->Style >> fsBold;
RichEdit->DefAttributes->Style >> fsBold;
RichEdit->Lines->Add("This should be normal\n");


Hi Brian,

Since the Font Style is a propertie, use

boldFont->Style = boldFont->Style << fsBold;

HTH
Antonio
Back to top
Brian
Guest





PostPosted: Sun May 06, 2007 6:59 pm    Post subject: Re: Adding formatted text programmatically Reply with quote



On May 5, 6:47 pm, "Antonio Felix"
<antoniojfe...@maisspamnao.clixempt> wrote:
Quote:
"Brian" <bvanma...@yahoo.com> escreveu na mensagemnews:1178407240.314126.312730 (AT) e65g2000hsc (DOT) googlegroups.com...





I need to add formatted text to a TRichEdit (or a TJvRichEdit if that
works better). I am trying things along the following lines, with no
luck:

TFont* boldFont = new TFont();
boldFont->Style << fsBold;
JvRichEdit->AddFormatText("This should be bold\n",boldFont);
TFont* normFont = new TFont();
JvRichEdit->AddFormatText("This should be normal\n",normFont);
JvRichEdit->AddFormatText("\nnow This should be
bold",TFontStyles(fsBold));
JvRichEdit->AddFormatText("\nnow This should be
normal",TFontStyles());

RichEdit->Font->Style = Errors->Font->Style << fsBold;
RichEdit->DefAttributes->Style << fsBold;
RichEdit->Lines->Add("This should be bold\n");
RichEdit->Font->Style = Errors->Font->Style >> fsBold;
RichEdit->DefAttributes->Style >> fsBold;
RichEdit->Lines->Add("This should be normal\n");

Hi Brian,

Since the Font Style is a propertie, use

boldFont->Style = boldFont->Style << fsBold;

HTH
Antonio- Hide quoted text -

- Show quoted text -

Thanks Antonio. That's exactly what I needed to do.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon May 07, 2007 10:17 pm    Post subject: Re: Adding formatted text programmatically Reply with quote

"Brian" <bvanmatre (AT) yahoo (DOT) com> wrote in message
news:1178407240.314126.312730 (AT) e65g2000hsc (DOT) googlegroups.com...

Quote:
RichEdit->Font->Style = Errors->Font->Style << fsBold;
RichEdit->DefAttributes->Style << fsBold;
RichEdit->Lines->Add("This should be bold\n");
RichEdit->Font->Style = Errors->Font->Style >> fsBold;
RichEdit->DefAttributes->Style >> fsBold;
RichEdit->Lines->Add("This should be normal\n");

You should be using the SelAttribtes property instead of the
DefAttributes property, ie:

RichEdit->SelStart = RichEdit->GetTextLen();
RichEdit->SelLength = 0;
RichEdit->SelAttributes->Assign(Errors->Font);
RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
fsBold;
RichEdit->SelText = "This should be bold\r\n";

RichEdit->SelStart = RichEdit->GetTextLen();
RichEdit->SelLength = 0;
RichEdit->SelAttributes->Assign(RichEdit->Font);
RichEdit->SelText = "This should be normal\r\n";


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.