创建一个firemonkey组件 [英] creating a firemonkey component

查看:259
本文介绍了创建一个firemonkey组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Delphi XE4中使用Firemonkey,我无法使用菜单项Component - > New Component创建一个新的组件。
组件是VCL还是Firemonkey组件,还是首先创建一个包,结果是一样的。
Delphi中的工具调色板似乎被搜索,并逐渐关闭,当它选择一个祖先组件时,它将空白组件和一个组件对话框,其中显示无可用项目。

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;


  • 在实现部分添加注册声明。

  • 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).

    这篇关于创建一个firemonkey组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆