Search code examples
delphidlltscrollbox

Show form from DLL in TScrollBox


I posted this online: Show form from DLL in TScrollBox

What i am trying to do is call and show a form in a Delphi TScrollBox. Not as Show or ShowModal

Example but not with any DLL:

Form1.Parent:= ScrollBox;
 Form1.Show;

How do i use this example from a DLL with a form inside

Can anyone provide an example?

Regards,


Solution

  • problem solved and here is the code:

    //This is the DLL
    
    library Project1dll;
    
    uses    
      SysUtils,    
      Windows,    
      Classes,    
      DllForm in 'DllForm.pas' {frmDllForm}; // this is the other form
    
    procedure Create_Form(ph: HWND);    
    begin    
      frmDllForm:= TfrmDllForm.CreateParented(Ph);    
      frmDllForm.Show;    
    end;
    
    Exports    
    Create_Form;
    
    begin    
    end.
    
    //---------------------END--------------------------------------
    
    //This is the project
    
    unit Unit1;
    
    interface
    
    uses    
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls;
    
    type    
      TForm1 = class(TForm)    
        Button1: TButton;    
        ScrollBox: TScrollBox;    
        procedure Button1Click(Sender: TObject);    
      private    
      end;
    
    procedure Create_Form(ph: HWND) ; external 'Project1dll.dll' name 'Create_Form';
    
    var    
      Form1: TForm1;
    
    implementation
    
    {$R *.DFM}
    
    function ScrollBoxDll(ph: HWND): Pointer; stdcall;    
    begin    
      Create_Form(ph);    
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);    
    begin    
      ScrollBoxDll(ScrollBox.Handle);    
    end;
    
    end.