Alternatives to DLL?
I was wondering is there any way that I can have a main form compiled into a EXE and EACH SECONDARY FORM COMPILED INDIVIDUALLY and then dynamically load in these other secondary forms in runtime ( DLL concept)
Why not?
(* The DLL unit *)
library MyLib;
type
TMyDLLForm = class(TForm)
...
end;
{$IF dynamically creation}
function CreateForm: TForm; {$IFDEF WIN32} stdcall;{ENDIF} export;
begin
Result := TMyDLLForm.Create(Nil);
Result.OnClose := @FreeForm;
end;
{$ELSE}
var
MyDllForm: TForm;
function CreateForm: TForm; {$IFDEF WIN32} stdcall;{ENDIF} export;
begin
Result := MyDLLForm;
end;
{$ENDIF}
exports
CreateForm;
end.
(****************)
(* The Main Form in exe module. Calling the MyDLLForm *)
function CreateForm: TForm; {$IFDEF WIN32} stdcall;{ENDIF} external
'MyLib';
procedure TMyMainExeForm.OnOpenDllFormBtnClick(Sender: TObject);
var
form: TForm;
begin
form := CreateForm;
form.owner := self;
form.parent := self;
end;
|