【问题标题】:How to create a component at runtime, equivalent to design time如何在运行时创建组件,相当于设计时
【发布时间】:2023-03-07 02:54:01
【问题描述】:

我想在运行时创建一个 TscStyledForm 组件,而不是在设计时将它放在表单上。 (这个来自 www.almdev.com 的组件修复了一些 VCL 样式问题)

如果我在Form构造函数中创建(如下),行为与设计时组件的行为略有不同(标题栏字体不正确):

  TForm2 = class(TForm)
  private
    { Private declarations }
    FStyledForm: TscStyledForm;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;
...

{ TForm2 }

constructor TForm2.Create(AOwner: TComponent);
begin
  inherited;
  FStyledForm := TscStyledForm.Create(Self);
end;

如果我在 CreateWnd 中创建组件,那也不能解决问题。

是否可以在运行时精确模拟设计时组件的创建?

【问题讨论】:

  • 你可能需要问开发者

标签: delphi components runtime


【解决方案1】:

如果你在你的Delphi中安装GExperts,你可以直观地创建组件,然后右键单击它并选择“要编码的组件”。这将生成与可视化创建组件的当前设置等效的 Pascal 源代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-14
    • 2017-02-24
    • 2010-11-03
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    相关资源
    最近更新 更多