creating a firemonkey component

雨燕双飞 提交于 2019-12-04 05:56:37

问题


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.

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.


回答1:


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.

  • Add a call to RegisterFMXClasses in your initialization section.

    implementation
    uses FMX.Types;
    ...
    initialization
      RegisterFMXClasses([TMyComponent]);
    end.
    
  • Create a package.

  • Add the unit to the package.
  • Right-click the package (in the top-right panel) and select Install.

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



来源:https://stackoverflow.com/questions/19106634/creating-a-firemonkey-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!