我試圖用FireMonkey平臺(XE7)創建一個非常簡單的組件(Tgraph)。首先,我創建了兩個新類: 1)TGraph(anchestor type TLayout); 2)TMyPlot1D(anchestor type Tpanel); 我保存了兩個單元並創建了一個名爲「MyPackage」的包。我編譯並安裝在「Samples」頁面中。我打開了一個新的Firemonkey項目,並將TGraph實例拖放到窗體中。一切運作良好。在設計時,我可以看到已定義的組件,並且所有相關單元都可以從主單元看到。相關的代碼是在以下幾點:FireMonkey組件執行錯誤
頭等艙
unit UMyPlot;
interface
uses
System.SysUtils, System.Classes, FMX.Types,
FMX.Controls, FMX.StdCtrls;
type
TMyPlot1D = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyPlot1D]);
end;
end.
二等
unit UMyGraph;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls, FMX.Layouts,
UMyPlot;
type
TMyGraph = class(TLayout)
private
Plot : TmyPlot1D;
public
constructor create(Aowner:TComponent); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyGraph]);
end;
constructor TMyGraph.create(Aowner: TComponent);
begin
inherited;
Plot := TMyPlot1D.Create(Self);
plot.Parent := Self;
end;
end.
,當我嘗試運行我的應用程序的問題所示。 我得到了以下錯誤: 「在模塊Project1.exe在000A51FA。類未找到類TmyPlot1D異常EClassNotFound」。失敗的函數似乎是Application.RealCreateForms。
如果我只拖放TmyPlot1D實例,它在設計時和運行時都會起作用(當然)!
任何想法?
在此先感謝
非常感謝。現在看來工作。 – Damiano 2015-04-02 12:34:13