我编写了一个动态库,在其中创建了一个TFrame对象。要求能够在主程序中把这个TFrame对象显示在TPanel组件中,目前的状态是无法显示TFrame对象,在动态库中修改TFrame的Width、Height属性可以使得TPanel的AutoSize属性起作用。请问如何编写代码另外,一个问题如何把TFrame的ParentFont属性设置成true时,执行TFrame.Parent:=panel时报“无法把Font对象赋给Font对象”function ShowDLLTestFrame4(panel:TForm):boolean;
begin
Result:=false;
dllFrame1:=TfrmDLLFrame.Create(Application);
dllFrame1.Parent:=panel;
result:=true;
end;
begin
Result:=false;
dllFrame1:=TfrmDLLFrame.Create(Application);
dllFrame1.Parent:=panel;
result:=true;
end;
如果是动态连接库的就会出问题
dll中创建TFrame的代码如下:function CreateAFrame(App: TApplication,AScreen:TScreen): TFrame;stdcall;
var
p: ^LongInt;
begin
Screen := AScreen;
Application := App;
p := @(Application.MainForm);
p^ := LongInt(App.MainForm);
Result := TfrmDLLFrame.Create(Application);
end;第二个程序使用如下:function TFrom1.GetFrameFromDll : boolean;
begin
FFrameFromDll := CreateAFrame(Application,Screen);
FFrameFromDll.parent := self;
FFrameFromDll.Align := alClient;
end;
begin
Result:=false;
dllFrame1:=TfrmDLLFrame.Create(Panel);
dllFrame1.Parent:=panel;
result:=true;
end