Board index » delphi » Richedit SelAttributes Font

Richedit SelAttributes Font

How does one properly get the current font settings of the selected text in
a RichText object?  I'm using a popup to display some options whem right
clicking the object.  If the user chooses Font from this menu then I display
a font dialog box.  What's happening with what I'm doing is that the
selected text's font settings don't show up in the font dialog box until the
2nd right click.  In other words, the settings are one click behind.  Here's
the code:

procedure Tform.FontDialog1Show(Sender: TObject);
begin
  FontDialog1.Font.Name := reText.SelAttributes.Name;
  FontDialog1.Font.Pitch := reText.SelAttributes.Pitch;
  FontDialog1.Font.Color := reText.SelAttributes.Color;
  FontDialog1.Font.Size := reText.SelAttributes.Size;
  FontDialog1.Font.Style := reText.SelAttributes.Style;
end;

--

Don Gollahon
(dlgl...@theinter.com)

 

Re:Richedit SelAttributes Font


Quote
In article <3b5d12d2$1_2@dnews>, Don Gollahon wrote:
> How does one properly get the current font settings of the selected text in
> a RichText object?  I'm using a popup to display some options whem right
> clicking the object.  If the user chooses Font from this menu then I display
> a font dialog box.  What's happening with what I'm doing is that the
> selected text's font settings don't show up in the font dialog box until the
> 2nd right click.  In other words, the settings are one click behind.  Here's
> the code:

> procedure Tform.FontDialog1Show(Sender: TObject);
> begin
>   FontDialog1.Font.Name := reText.SelAttributes.Name;
>   FontDialog1.Font.Pitch := reText.SelAttributes.Pitch;
>   FontDialog1.Font.Color := reText.SelAttributes.Color;
>   FontDialog1.Font.Size := reText.SelAttributes.Size;
>   FontDialog1.Font.Style := reText.SelAttributes.Style;

Change this to Fontdialog1.Font.Assign( reText.SelAttributes );

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Other Threads