Jump to content

Connect TFrame from BPL to MainForm


artem_niko

Recommended Posts

On 8/27/2021 at 9:39 AM, herculanojs said:

Greetings!

Forgive me for asking questions, but please help me with one more thing. Look.

1. I start MainProject:

1754565316_.png.5c145ccc7949cb6c98e474570820b854.png

The application starts. Everything seems to be fine, judging by the files:

1048007604_.png.708abf8a5f9ef51a639fdddf688a6063.png

2. I click the Connect BPL button and connect the frame:

1762431498_.png.336ca4aefbfd308d8c123240f4104270.png

The connected BPL is displayed in a frame. Everything is fine, as it should be, everything works, the project works. Then I needed to make changes to the BPL and reconnect it. Let's say I did that, made changes to the BPL. 

For example, I change the color of the panel and try to compile the BPL:

1542923265_.thumb.png.309d34a3b827be2bf0a6292fe8a8ee00.png

Like BPL compiles:

159714507_.png.22ff0c41560778d828b122db97e38f9c.png

At the same time, some strange file with a tilde is created in the directory of the main project where BPL is compiled (I understand that this is some temporary one, apparently):

1999055446_.png.aaca68135f5794985adb8889880247fd.png

Now I, in the main project, press the button and Free Frame + unloadpackage and unload the BPL:

1754565316_.png.5c145ccc7949cb6c98e474570820b854.png

Now, I want to connect the updated BPL package again, but the updated BPL is not connected, but the previous one is connected:

1762431498_.png.336ca4aefbfd308d8c123240f4104270.png

Ultimately, the updated BPL is connected only if the project server is stopped, closed, and restarted. Only after this action is the updated BPL connected:

668567423_.png.603ca7de5cbfb7d5f65aca7d263ed1fc.png

 

Help me finish it so that you don't have to stop the main project, but you can reconnect the BPL without stopping the main project.

Is it realistic to do it?

MainProject_new.zip

Link to comment
Share on other sites

6 hours ago, artem_niko said:

 

Hello,

I saw your interest in using BPL. This is an old technique from the time of Delphi 5, to get a small .exe file and for better memory management. Today, with the performance of the hardware used, we no longer need to worry about all that. Apart from occasional, well-targeted updates.

Coud you please, tel us

Why do you still want to use BPL packages?

Link to comment
Share on other sites

  • 3 weeks later...

I have an application (standard vcl) which exceeds 40MB in exe and after reading your topic, I was tempted to compile it with its packages.

Results

Here is the summary of my research. I found that there are more cons than pros:

1. Benefits :

- you barely gain some 10 MB for the exe

- The updates would be punctual: would only point to part of the changed code.

- Economy and better RAM management if several applications (with bpl and developed with the same Delphi version) are installed on the same client PC

 

2. Disadvantages:

- The Setup CD would be huge (since it would contain all the Bpl packages)

- If you change Delphi version, you must redistribute the new BPL packages

- the program becomes less stable

- Problem with Tracking memory leak

- what about Reverse ingeneering problem ? you should find more robust protection.

Regards

 

https://stackoverflow.com/questions/1898560/why-does-building-with-runtime-packages-make-the-exe-file-smaller

Link to comment
Share on other sites

  • 2 weeks later...
3 hours ago, Abaksoft said:

Thx.

Could you please explain in more details. I am curious to see that.

That is, the module code is written in the DLL, and the basic code is written in the framework body [such as connecting data, calling permission, etc.]

DLL and framework body interact with each other through Delphi internal interface

Of course, my framework can be separated from Delphi development [i.e. online runtime development], but some special functions still need to be encapsulated by modular DLL. My DLL can support unifrom and uniframe, and can also register the functions and processes inside the framework

Link to comment
Share on other sites

5 hours ago, 风吹小机机 said:

My DLL can support unifrom and uniframe, and can also register the functions and processes inside the framework

Great :)

Something like this ?

procedure DoingSomething; stdcall; external 'toto.dll';

With  DoingSomething on Unigui Side and toto.dll  a classical Delphi DLL ?

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 7 months later...
On 8/22/2021 at 10:48 PM, herculanojs said:

image.png.53cedcc7ba11bd5f3b76834ed2cc9c61.png

image.thumb.png.c890c984ace8faa89024ee49114db62a.png

image.png.01af1cdf8b51f39a1bde01a73867e6c8.png

image.png.c013398cc152aafedf2a1d4f3c91d405.png

Hello!

Is it possible transfer HModule from MainForm, using code?

As, by analogy for string values:

var
  MyHModuleVar: HMODULE;
begin
...
if IsPublishedProp(UniFrame1,'GV_Test') then
   SetPropValue(UniFrame1,'GV_Test',MyHModuleVar);
...

In UniFrame1:

 ...
private
    procedure SetGlobalValue(const MyHModuleVar: HMODULE);
...

and:

... 
published
    property GV_Test: hmodule read GetttingValue write SetGlobalValue;

It seems to work, my HModule variable is passed, but when I use the UnloadPackage(MyHModuleVar) function in UniFrame1, I get an AV error...

Link to comment
Share on other sites

Hello, again!)

Well, I'll try to explain what I've done so far.
So, in the main application, I prescribed:

...
private
    procedure SetGlobalValue_UnloadingBPL(const Value: HModule);
public
    test1, test2: HModule; //test1 - что передаю, test2 - для обратного получения в главное приложение
    property GV_UnloadingBPL: HModule read UnloadingBPL write SetGlobalValue_UnloadingBPL;
...

The code of the button for passing the variable to the frame:

...
    if IsPublishedProp(Frame1,'GV_UnloadingBPL') then
       SetPropValue(Frame1,'GV_UnloadingBPL',test1);
...

Now I get my variable in the frame itself:

...
private
    procedure SetGlobalValue_GettingBPL(const Value: HModule);
public
    FG_GettingValue: HModule; //куда запоминаю переменную
    property GV_UnloadingBPL: HModule read FG_GettingValue write SetGlobalValue_GettingBPL;
...

Code for getting a variable in a frame:

procedure TUniFrameG1.SetGlobalValue_GettingBPL(const Value: NativeUInt);
begin
  FG_GettingValue:=Value;
end;

And here is the code when the frame closes (it closes by timer):

procedure TUniFrameG1.UniTimer_CloseTimer(Sender: TObject);
begin
      if IsPublishedProp(Self,'test2') then
         SetPropValue(Self,'test2',FG_GettingValue);
end;

Then, I try to unload the BPL in the main program when closing TabSheet1:

procedure TMainForm.UniTabSheet1_Close(Sender: TObject; var AllowClose: Boolean);
begin
  SetGlobalValue_UnloadingBPL(test2);

  if test2<> 0 then
  begin
    ShowMessage('Пакет загружен');
    UnloadPackage(test2);
  end;
end;

And so, when doing all this, I get an error in the main program: Invalid package handle

Please, help me...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...