Board index » cppbuilder » RichEdit Text Bolding

RichEdit Text Bolding


2007-12-30 05:02:57 AM
cppbuilder75
Is it that I am helplessly stupid or is it that I attempt to do odd tasks.
In a RichEdit, I want to change the color and bold the following text using:
RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
fsBold;
"^" (including the two double quotes)
The font name that I am using is Courier New (this fact seems to be of
significance).
The color is always changeable (no problem).
For font size = 10, I cannot bold the text.
For other font sizes (12, 14, etc.), I CAN change to bold.
Now, if I change the "^" to "Z", for instance, the bolding works for any
font size.
On a slightly different topic, while poking around trying to solve the above
problem,
I became aware that I am unable to modify either the font name or font size
at run time.
Statements like:
RichEdit->Font->Name = "Courier New";
RichEdit->Font->Height = -24;
RichEdit->Update();
don't seem to take effect. I followed a little of the de{*word*81} CPU control
flow,
and it would appear that logical system functions are being called.
Richard
 
 

Re:RichEdit Text Bolding

Hi Richard
Have You tried:
RichEdit->SelStart = 12;
RichEdit->SelLength = 40;
RichEdit->SelAttributes->Size = 12;
RichEdit->SelAttributes->Name = "Courier New";
void __fastcall TForm1::Button6Click(TObject *Sender)
{
if(RichEdit->SelAttributes->Style.Contains(fsBold))
RichEdit->SelAttributes->Style = RichEdit->Font->Style>>fsBold;
else
RichEdit->SelAttributes->Style = RichEdit->Font->Style << fsBold;
}
//------------------------------------------------------------
In my test everything can change to bold also "^" but
the " just gets a little longer.
Kind regards
Asger
 

Re:RichEdit Text Bolding

"Richard" < XXXX@XXXXX.COM >wrote in message
Quote
In a RichEdit, I want to change the color and bold the following
text using:
RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
fsBold;
"^" (including the two double quotes)
You did not show how you are actually adding the text to the RichEdit after
changing the settings. The SelAttributes property only affects the selected
area, or only the current insertion point if there is no selection. In
either case, you should be using the SelText property to insert the text, if
you are not already, ie:
RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
fsBold;
RichEdit->SelText = "^";
Quote
For font size = 10, I cannot bold the text.
Worked fine for me when I just tried it.
Quote
I became aware that I am unable to modify either the font
name or font size at run time.
Yes, you can.
Quote
Statements like:
RichEdit->Font->Name = "Courier New";
RichEdit->Font->Height = -24;
RichEdit->Update();
don't seem to take effect.
Yes, they do. However, they effect the entire RichEdit content as a whole,
not the selected/insertion area. Again, they work perfectly fine when I
just tried them.
Gambit
 

{smallsort}

Re:RichEdit Text Bolding

Remy,
1) I did not add text AFTER changing font. The text was there, and I
expected to see
it change form.
2) What is the best way to show you EXACTLY how I placed text into the memo?
There is the main program, its *.h file and a third file which has the
"work" routines.
I have stripped out all extraneous lines from all files, but they are
not tiny
(maybe a couple of hundred lines all together).
Should I just paste them into a post like this?
3) I may be out of town Fri. for a week.
Thanks,
Richard
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Richard" < XXXX@XXXXX.COM >wrote in message
news:4776b5fd$ XXXX@XXXXX.COM ...

>In a RichEdit, I want to change the color and bold the following
>text using:
>RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
>fsBold;
>"^" (including the two double quotes)

You did not show how you are actually adding the text to the RichEdit
after
changing the settings. The SelAttributes property only affects the
selected
area, or only the current insertion point if there is no selection. In
either case, you should be using the SelText property to insert the text,
if
you are not already, ie:

RichEdit->SelAttributes->Style = RichEdit->SelAttributes->Style <<
fsBold;
RichEdit->SelText = "^";

>For font size = 10, I cannot bold the text.

Worked fine for me when I just tried it.

>I became aware that I am unable to modify either the font
>name or font size at run time.

Yes, you can.

>Statements like:
>RichEdit->Font->Name = "Courier New";
>RichEdit->Font->Height = -24;
>RichEdit->Update();
>don't seem to take effect.

Yes, they do. However, they effect the entire RichEdit content as a
whole,
not the selected/insertion area. Again, they work perfectly fine when I
just tried them.


Gambit


 

Re:RichEdit Text Bolding

"Richard" < XXXX@XXXXX.COM >wrote in message
Quote
1) I did not add text AFTER changing font. The text was there,
and I expected to see it change form.
It will, if you are updating it correctly. In order to change a portion of
existing text, you must select it first via the SelStart and SelLength
properties (or via mouse/keyboard input), as the SelAttributes property only
affects the current selection. Changing the main Font property updates the
entire text instead.
Quote
2) What is the best way to show you EXACTLY how I placed text into the
memo?
Show your actual code.
Quote
Should I just paste them into a post like this?
Post the actual project (or a test project that demonstrates the same
problem) to the borland.public.attachments newsgroup.
Gambit