crestty
asked on
load a packge at runtime; and show Form
here is my code for the on click event to load
the packed and show the Form.
I am unable to show the Form...
AClass = 0 when i Debug it ,, as if the
Class never registers.
var
PackageModule: HModule;
AClass: TPersistentClass;
begin
PackageModule := LoadPackage(ExtractFilePat h(ParamStr (0))
+ 'AbtPack.bpl');
if PackageModule <> 0 then
begin
AClass := GetClass('TFormAbout');
if AClass <> nil then
with TComponentClass(AClass).Cr eate(Appli cation)
as TCustomForm do
begin
ShowModal;
Free;
end
else
ShowMessage('Class not registered');
UnloadPackage(PackageModul e);
end
else
ShowMessage('Package not found');
end;
Here is my Package ini secetion / declaration
type
TFormAbout = class(TForm)
LabelVer: TLabel;
Label2: TLabel;
.....
initialization
begin
RegisterClass(TFormAbout);
end;
finalization
begin
UnRegisterClass(TFormAbout );
end;
the packed and show the Form.
I am unable to show the Form...
AClass = 0 when i Debug it ,, as if the
Class never registers.
var
PackageModule: HModule;
AClass: TPersistentClass;
begin
PackageModule := LoadPackage(ExtractFilePat
+ 'AbtPack.bpl');
if PackageModule <> 0 then
begin
AClass := GetClass('TFormAbout');
if AClass <> nil then
with TComponentClass(AClass).Cr
as TCustomForm do
begin
ShowModal;
Free;
end
else
ShowMessage('Class not registered');
UnloadPackage(PackageModul
end
else
ShowMessage('Package not found');
end;
Here is my Package ini secetion / declaration
type
TFormAbout = class(TForm)
LabelVer: TLabel;
Label2: TLabel;
.....
initialization
begin
RegisterClass(TFormAbout);
end;
finalization
begin
UnRegisterClass(TFormAbout
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
crestty:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
nit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
PackageModule: HModule;
AClass: TPersistentClass;
begin
PackageModule := LoadPackage('Package1.bpl'
if PackageModule <> 0 then
begin
AClass := GetClass('TForm2');
if AClass <> nil then
with TComponentClass(AClass).Cr
as TCustomForm do
begin
ShowModal;
Free;
end;
UnloadPackage(PackageModul
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterClass(TForm2);
end;
procedure TForm1.FormDestroy(Sender:
begin
UnRegisterClass(TForm2);
end;
end.
best regards
Cesario