In the programming of the MDI Form, how the main form (FSMDIFORM) is called a child form (FSMDICHILD, this subform is DLL). The following is my original code: ================================================ =============================================== DPR unit code
Program MDIFORM;
Uses form, umdiform in 'umdiform.pas' {mainform}, udm in 'udm.pas' {globaldm: tdatamodule}, ufun in 'ufun.pas';
{$ R * .res}
Begin Application.initialize; Application.createForm (TMAINFORM, MainForm); Application.Run; end. ============================== ============================================================================================================================================================================================================= ================
Main Code form: unit UMdiform; interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Udm, StdCtrls; type TMainform = class (TForm) Button1: TButton; procedure Button1Click (Sender: TObject); Procedure formcreate; private {private declarations} public myhandle: hwnd; {public declarations} end;
Var mainform: tMAINFORM;
TYPE T_SHOWTESTMNG = Function (VAR ADM: TMAINFORM): Boolean; stdcall; importation {$ 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;
Procedure tMainform.form.form.formcreate (Sender: TOBJECT); Begin myHandle: = Application.Handle; End;
End. ================================================= ==============================================
Subform DLL code: library mdichild;
Uses ShareMem, UmdiForm, // This unit is a parent window, and I have set a search in the path in the top set. FormStyle properties for Forms, Sysutils, Classes, Uchild In 'uchild.pas' {frmchild}; //frmChild}; FormStyle properties for FSMDICHILD
{$ R * .res} function _showtemng (var adm): boolean; stdcall; begin result: = true; application.handle: = adm.myhandle; application.createform (tfrmChild, fmchild); // The program is wrong This: The reason for the error is: Cannot Create Form. No MDI Forms Are Currently Active. FmChild.show; end;
EXPORTS _SHOWTESTMNG; END.