How can I work with ‘packages dynamically loaded’ which contain forms inside them?

Written by Francisco R.

The executable you are going to use to load those dynamical packages (dpl, bpl) must have enabled the ‘Build with runtime packages‘ option, besides, on the edition’s field corresponding to this option must appear the name of the JfControls’ package(s) that that executable will use, thus: JfCtrls_d6;JfCtrlsGrid_d6

This option should be at ‘Project Options‘ / Packages Tab.

In addition, this edition’s field must also include all those packages of Delphi you also want to use along your application.

You must register each and every package’s unit (dpl, bpl) with a form inside as follows:

initialization
  RegisterClass(TFrForm1);
finalization
  UnRegisterClass(TFrForm1);

To create those forms within the dynamical packages, you should use the following JfControls functions:

procedure JfWndPkgCreate(AOwner: TCustomForm; var AForm: TForm; ALibrary: String; AFormClass: String; ACenterOptions: TJfCenterOptions);
procedure JfWndPkgCreateModal(AOwner: TCustomForm; var AForm: TForm; ALibrary: String; AFormClass: String; ACenterOptions: TJfCenterOptions);
procedure JfWndPkgShow(AOwner: TCustomForm; var AForm: TForm; ALibrary: String; AFormClass: String; ACenterOptions: TJfCenterOptions);
function JfWndPkgShowModal(AOwner: TCustomForm; var AForm: TForm; ALibrary: String; AFormClass: String; ACenterOptions: TJfCenterOptions): TModalResult;

For instance:

 TFrMain = class(TForm)
    JfCApp: TJfCApplication;
    CForm: TJfCForm;
    JfSpeedButton1: TJfSpeedButton;
    JfSpeedButton2: TJfSpeedButton;
    procedure JfSpeedButton1Click(Sender: TObject);
    procedure JfSpeedButton2Click(Sender: TObject);
    procedure CFormFormDestroy(Sender: TObject);
  private
    { Private declarations }
    f1, f2: TForm;
  public
    { Public declarations }
  end;
procedure TFrMain.JfSpeedButton1Click(Sender: TObject);
begin
  JfWndPkgShow(Self, f1, 'FormsPkg.dpl', 'TFrForm1', ceoPriorWindow);
end;
procedure TFrMain.JfSpeedButton2Click(Sender: TObject);
begin
  JfWndPkgShow(Self, f2, 'FormsPkg.dpl', 'TFrForm2', ceoPriorWindow);
end;
procedure TFrMain.CFormFormDestroy(Sender: TObject);
begin
  if Sender = f1 then f1 := nil;
  if Sender = f2 then f2 := nil;
end;

Version: 1.0.0

Size: 28 KB

Published: August 12, 2020

Packages Dynamically loaded Sample (Delphi 3)

Available in: JfControls Standard, Developer and Professional


Version: 1.0.0

Size: 30 KB

Published: August 12, 2020

Packages Dynamically loaded Sample (Delphi 5)

Available in: JfControls Standard, Developer and Professional


Version: 1.0.0

Size: 30 KB

Published: August 12, 2020

Packages Dynamically loaded Sample (Delphi 6)

Available in: JfControls Standard, Developer and Professional



You may also like…

JfControls 21.07.09 released

JfControls 21.07.09 released

Today we are excited to introduce the new version of JfControls 21.07.09 compatible with RADStudio 10.4. Improvements ... ⦁ Improvements in compatibility with Delphi 10.3.3 and CBuilder 10.3.3 (32Bit & 64Bit). ⦁ Compatibility with Delphi 10.4 and CBuilder 10.4...

0 Comments

Submit a Comment