gpt4 book ai didi

delphi - 组件编辑器不会立即提示保存新的属性值

转载 作者:行者123 更新时间:2023-12-03 18:18:37 25 4
gpt4 key购买 nike

我有一个自定义控件,它有一个组件编辑器(通过两个不同的上下文菜单项可以使用两个不同的屏幕)。在这两种情况下,当我更改正在编辑的组件的属性时,IDE 不会确认已进行任何更改,因此 Delphi IDE 中的“全部保存”按钮保持不活动状态(假设它在更改之前处于不活动状态) .

虽然属性更改已明确应用于设计时控件,但如果我立即运行该项目,从组件编辑器完成的更改并未在运行时应用。我不得不在表单设计器/对象检查器中进行细微调整以触发启用“全部保存”按钮,这样我才能真正保存更改。

下面是我如何执行上下文菜单选择:

TMyControlEditor 派生自 TDefaultEditor

procedure TMyControlEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: begin
ExecEditor;
end;
1: ...
end;
end;

procedure TMyControlEditor.ExecEditor;
var
F: TfrmMyControlEditor;
begin
F:= TfrmMyControlEditor.Create(TMyControl(Component));
try
case F.ShowModal of
mrOK: begin
F.SaveTo(TMyControl(Component));
end;
end;
finally
F.Free;
end;
end;

procedure TfrmMyControlEditor.SaveTo(ADst: TMyControl);
begin
ADst.ThisProperty:= chkThisProperty.Checked;
ADst.ThatProperty:= txtThatProperty.Text;
ADst.Width:= seWidth.Value;
ADst.Height:= seHeight.Value;
ADst.Visible:= chkVisible.Checked;
... set other properties ...
end;

这甚至发生在我什至没有重新引入的属性上,例如 VisibleWidth。如果我从这个属性编辑器更改任何属性,它会立即在对象检查器中向我显示该更改。但是,IDE 的其余部分不承认任何更改,因此不给我保存更改的选项。

当对我的控件的属性进行更改时,如何让 IDE 确认?

最佳答案

DesignIntf​​.pasIComponentEditor 接口(interface)的注释有一些建议:

Whenever the component modifies the component is must call Designer.Modified to inform the designer that the form has been modified.

有一些拼写错误,但要点很清楚:您的组件编辑器需要调用 Designer.Modified

关于delphi - 组件编辑器不会立即提示保存新的属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28778019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com