0

Sorry if this question has been asked in the past, but i'm confused!

I have an app and a DLL, both in Delphi. The Dll has a form that i want to show(no modal) inside a Groupbox. In the main app i have enabled runtime packages. In the DLL if i disable them, then works ok with the code bellow.

in DLL :

procedure showInfo(app : Thandle; GB : TGroupBox); stdcall;
begin
   // application.Handle := app; // are the same
    FormSysInfo := TFormSysInfo.CreateParented(GB.handle);
    FormSysInfo.show;
end;

procedure destroyInfo; stdcall;
begin
    FormSysInfo.destroy;
end;

exports showInfo    index 1,
        destroyInfo index 2; 

in main app :

procedure loadSysInfo;
var showInfo : procedure(app : Thandle; GB : TGroupBox); stdcall;
begin
    sysInfo := LoadLibrary('SysInfo.dll');
    if sysInfo <> 0 then begin
        @showInfo := GetProcAddress(sysInfo, 'showInfo');
        @destroyInfo := GetProcAddress(sysInfo, 'destroyInfo');
        if @showInfo <> NIL then      showInfo(application.handle,mainForm.GroupBox8);
    end;
end;

but didn't show if i enable runtime packages for the DLL (I want to reduce the size). How can i manage this, please ? thanks in advance

JimPapas
  • 715
  • 2
  • 12
  • 27
  • VCL isn't designed for such abuse. You are expected to use runtime packages everywhere. Once you do so you don't need to screw around with `CreateParented`. You can just set the `Parent` property in the usual way. – David Heffernan Aug 16 '16 at 10:02
  • I forgot to mention that, if i enable runtime packages for the DLL, then the main app fails to load the library (@showInfo := GetProcAddress(sysInfo, 'showInfo') gives zero!) so the DLL can't execute at all. – JimPapas Aug 16 '16 at 10:24
  • 3
    Perhaps you should solve that problem then. If you are going to use runtime packages you really need to be all in. Change your DLL to be a runtime package. Your code is dodgy at best because you pass a `TGroupBox` instance down and that is only meaningful if all parties use runtime packages. You ought to pass down a window handle really. But what about window recreation. That will screw you good and proper. Separating UI into lots of modules is a painful process. My advice is don't do it. One big EXE and all problems vanish. If you must do it, one EXE and everything else a package. – David Heffernan Aug 16 '16 at 10:27
  • Finally i'll make one big EXE, but still i'm wondering why. – JimPapas Aug 16 '16 at 18:07
  • because DLLs are fundamentally different than BPLs, just read runtime library what troubles it takes to check and patch different RTL structures for different ways Windows is loading/unloading EXE ad DLL and BPL. Mixing so different approach is like trying to make helicopter submarine - it would fail on both sides. You really better convert your DLL into BPL and use VCL the way it was designed to be used since Delphi 3 in 1997 – Arioch 'The Aug 16 '16 at 18:17
  • I tried to make BPL instead of DLL but i failed to register the form (although i followed this http://edn.embarcadero.com/article/27178 article) so i tried DLL. I'm not experienced programmer. Any help is valuable, thanks. – JimPapas Aug 16 '16 at 18:35

0 Answers0