Below is my original Code :
========================================================== ========================================================== ============
DPR unit code
Program mdiform;
Uses
Forms,
Umdiform in 'umdiform. pa' {mainform },
UDM in 'udm. pa' {globaldm: tdatamodule },
Ufun in 'ufun. pa ';
{$ R *. Res}
Begin
Application. initialize;
Application. createform (tmainform, mainform );
Application. Run;
End.
========================================================== ========================================================== ====================
Main form code:
Unit umdiform;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, UDM, stdctrls;
Type
Tmainform = Class (tform)
Button1: tbutton;
Procedure button1click (Sender: tobject );
Procedure formcreate (Sender: tobject );
Private
{Private Declarations}
Public
Myhandle: hwnd;
{Public declarations}
End;
VaR
Mainform: tmainform;
Type
T_showtestmng = function (var adm: tmainform): Boolean; stdcall;
Implementation
{$ R *. DFM}
Procedure tmainform. button1click (Sender: tobject );
VaR
Lib _: thandle;
_ Showtestmng: t_showtestmng;
Begin
Lib _: = loadlibrary (pchar ('mdichild. dll '));
Try
@ _ Showtestmng: = getprocaddress (LIB _, '_ showtestmng ');
If not (@ _ showtestmng = nil) then
_ Showtestmng (mainform );
Finally
Freelibrary (LIB _);
End;
End;
Procedure tmainform. formcreate (Sender: tobject );
Begin
Myhandle: = application. Handle;
End;
End.
========================================================== ========================================================== ====================
Sub-form DLL code:
Library mdichild;
Uses
Sharemem,
Umdiform, // This unit is the parent form unit. In the top object settings, I have set to search for this unit in the path.
Forms,
Sysutils,
Classes,
Uchild in 'uchild. pa' {frmchild}; // The formstyle attribute of the frmchild child form is fsmdichild.
{$ R *. Res}
Function _ showtestmng (var adm: tmainform): Boolean; stdcall;
Begin
Result: = true;
Application. Handle: = adm. myhandle;
Application. createform (tfrmchild, frmchild );// Program This error occurs because cannot create form. No MDI forms are currently active.
Frmchild. show;
End;
Exports
_ Showtestmng;
End.