我从 Delphi v7 迁移到 Delphi XE2。我正在尝试使用带有两个 dbrichedit 和一个 dbedit 控件的 fontdialog。我用来完成任务的代码在 Delphi v7 中运行良好,但不适用于 XE2。我想这一定是我忽略了一些简单的事情。我已经解决这个问题一个多星期了,但我认为我离问题太近了,看不到它。
我使用了一个按钮来执行 fontdialog 和一个应用事件来操作文本。
代码:
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)
没发生什么事。
是否有我忽略的 form1 属性?
最佳答案
您必须保存 ActiveControl
的值变量中的属性,在使用它之前,因为当 Vcl.Dialogs.TFontDialog.OnApply事件引发 ActiveControl
返回当前事件控件,在这种情况下是您按下的按钮。检查这个样本 FontDialogOnApply (Delphi)
.
关于delphi - 使用 fontdialog 和 RichEdit 更改事件控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9999452/