Board index » delphi » Richedit and font changing

Richedit and font changing

Just running the demo program that comes with D3 / D4 for TRichEdit,
when I type in some text and then change the font (without selecting
any text) all the previous text changes font as well instead of
changing the font for 'new' text.

It also does the same when loading a file (the overview.rtf for
example).  Goto the end of the text and change the font and the 'Rich
Edit Control Overview' changes font as well!

It does this multiple machines (95 / NT) so what do I do about it??

Regards,
Greg.

S G Munn (sgm...@csi.com)
DNS Technology
Melbourne, Australia

 

Re:Richedit and font changing


Quote
In article <3737844c.291394...@forums.inprise.com>, S G Munn wrote:
> Just running the demo program that comes with D3 / D4 for TRichEdit,
> when I type in some text and then change the font (without selecting
> any text) all the previous text changes font as well instead of
> changing the font for 'new' text.

> It also does the same when loading a file (the overview.rtf for
> example).  Goto the end of the text and change the font and the 'Rich
> Edit Control Overview' changes font as well!

> It does this multiple machines (95 / NT) so what do I do about it??

It has been coded this way. The two key routined in the examples
remain.pas are

function TMainForm.CurrText: TTextAttributes;
begin
  if Editor.SelLength > 0 then Result := Editor.SelAttributes
  else Result := Editor.DefAttributes;
end;

and

procedure TMainForm.SelectFont(Sender: TObject);
begin
  FontDialog1.Font.Assign(Editor.SelAttributes);
  if FontDialog1.Execute then
    CurrText.Assign(FontDialog1.Font);
  SelectionChange(Self);
  Editor.SetFocus;
end;

CurrText returns either the selected texts TTextattributes object or,
if no text is selected, the DefAttributes. Changing the latter tends to
change the attributes of the whole text if it has uniform text
attributes.

You can cut CurrText out of the picture by changing this line in
SelectFont

  CurrText.Assign(FontDialog1.Font);

to

  Editor.SelAttributes.Assign( FontDialog1.Font );

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Richedit and font changing


"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote:

Quote
>You can cut CurrText out of the picture by changing this line in
>SelectFont

>  CurrText.Assign(FontDialog1.Font);

>to

>  Editor.SelAttributes.Assign( FontDialog1.Font );

Thanks, that helped just right.

Regards,
Greg
S G Munn (sgm...@csi.com)
DNS Technology
Melbourne, Australia

Other Threads