问题描述
我在 Delphi XE4 中使用 Firemonkey,但无法使用菜单项 Component -> New Component 创建新组件.无论组件是 VCL 还是 Firemonkey 组件,还是我先创建一个包,结果都是一样的.Delphi 中的 Tool Palette 似乎已被搜索并逐渐关闭,使其空无组件,并在选择祖先组件时显示No Items available"的组件对话框.
I'm working with Firemonkey in Delphi XE4 and I'm unable to create a new component using the menu item Component -> New Component.Whether the component is a VCL or Firemonkey component or whether I create a package first the result is the same.The Tool Palette in Delphi appears to be searched and gradually it closes leaving it empty of components and a component dialog box that says "No Items available" when it comes to selecting an ancestor component.
我有两个单独的 Delphi XE4 安装,并且两者都出现了相同的症状.似乎 Delphi 认为没有合适的基础组件来构建新组件.
I have two separate installations of Delphi XE4 and the same symptoms appear on both.It appears that Delphi believes that there are no suitable base components on which to build a new component.
推荐答案
在代码中创建组件相当简单.
Creating components is fairly straightforward in code.
- 创建一个单元.
- 为您的组件添加代码.
添加注册过程.
- Create a unit.
- Add code for your component.
Add a Register procedure.
procedure Register;
begin
RegisterComponents('NewPage', [TMyComponent]);
end;
在 implements 部分添加 Register 声明.
Add a declaration for Register in the implements section.
在初始化部分添加对 RegisterFMXClasses 的调用.
Add a call to RegisterFMXClasses in your initialization section.
implementation
uses FMX.Types;
...
initialization
RegisterFMXClasses([TMyComponent]);
end.
创建一个包.
Create a package.
(注意:通常最好在测试时在运行时创建您的组件.您只需要在包相当稳定后执行此操作).
(Note: It's usually best to create your component at run time whilst testing. You only need to do the package stuff once it's fairly stable).
这篇关于创建一个火猴组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!