Call the form in the DLL

xiaoxiao2021-03-06  42

(1) DLL source library ProjectDll; uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, UnitDll in 'UnitDll.pas' {Form1}; Form procedure // DLL in ProvaChild (ParentApplication: TApplication; ParentForm: TForm); export; stdcall; var Form1: TForm1; DllProc: Pointer; {Called whenever DLL entry point is called} begin Application: = parentApplication; Form1: = TForm1.Create (ParentForm); Form1.MyParentForm: = ParentForm; Form1.MyParentApplication: = parentApplication; // windows.SetParent (Form1.Handle, ParentForm.Handle); // Form1.FormStyle: = fsMDIChild; Form1.Show; end; procedure DLLUnloadProc (Reason: Integer); register; begin if Reason = DLL_PROCESS_DETACH THEN Application: = DLLApplication; End; Exports Provachild; Begin DLLApplication: = Application; DllProc: = @dllunloadProc; end. ======================= ====================== Unit UNITDLL; Interface Uses Windows, Messages, Sysutils, Classes, GRA phics, Controls, Forms, Dialogs; type TForm1 = class (TForm) procedure FormClose (Sender: TObject; var Action: TCloseAction); procedure FormDestroy (Sender: TObject); private public MyParentForm: TForm; MyParentApplication: TApplication; end; var DllApplication : Tapplication; IMPLEMENTATION {$ r * .dfm} Procedure TFORM1.FORMCLOSE (Sender: Tobject; var Action: tclosection); begin action: = cafree; end; procedure tform1.formdestroy (sender: TOBJECT) Download Adapt; @Ender: TFORM1.MMDESTROY (SENDER: TOBJECT);

转载请注明原文地址:https://www.9cbs.com/read-59821.html

New Post(0)