1

I migrated from Delphi v7 to Delphi XE2. I am trying to use a fontdialog with two dbrichedit and a dbedit control. The code I used to accomplish the task works fine in Delphi v7, but it does not work with XE2. I think it must be some simple thing I have overlooked. I have worked on resolving the issue for over a week, but I am too close to the problem to see it I think.

I used a button to execute fontdialog and an apply event to manipulate the text.

Code:

if ActiveControl is TDBEdit then 
  with ActiveControl as
  TdbEdit do
    Font.Assign(TFontDialog(Sender).Font)
else if ActiveControl is TDBRichEdit then 
  with ActiveControl as TDBRichEdit do
    SelAttributes.Assign(TFontDialog(Sender).Font)

Nothing happens.

Is there a property for form1 that I have overlooked?

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Robert
  • 61
  • 1
  • 14

1 Answers1

4

You must save the value of the ActiveControl property in a variable, before to use it, because when the Vcl.Dialogs.TFontDialog.OnApply event is raised the ActiveControl return the current active control which in this case is the button which you pressed. check this sample FontDialogOnApply (Delphi).

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Thank you for your reply. I did what you suggested and re-wrote my code after the example "FontDialogOnApply (Delphi). The problem still exists. When I highlight the text in my RichEdit controls and select text attributes in FondDialog, then click apply nothing happens. It is the same with the edit control. – Robert Apr 04 '12 at 18:19