我的MIDForm窗体上只放了菜单工具条.
code:
主调程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ToolWin;
type
// T_ProvaChild=procedure (ParentApplication:Tapplication;ParentForm:Tform;ParentScreen:Tscreen);stdcall;
T_ProvaChild=Procedure(MainApp:TApplication);stdcall;
TForm1 = class(TForm)
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
showmessage(inttostr(form1.MDIChildCount));
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
var
DllHandle: THandle;
ProcAddr: FarProc;
ProvaChild: T_ProvaChild;
begin
DllHandle := LoadLibrary('F:/Public_programs/His_sj/DLL_resource/mzgh/Mzgh.dll');
ProcAddr := GetProcAddress(DllHandle, 'ShowMdiChild');
if ProcAddr <> nil then
begin
ProvaChild := ProcAddr;
// ProvaChild(Application,Self,Screen);
ProvaChild(Application);
end;
end;
end.
DLL过程:
library Mzgh;
uses
SysUtils,
Classes, ADODB,DB,Forms, windows,
PublicPanel in '../../Class/PublicPanel.pas' {FrmPanel},
mzghFrm in 'mzghFrm.pas' {FrmMzgh},
DBShow in '../../Class/DBShow.pas';
var
SaveDLLApp:TApplication;
procedure ShowMdiChild(MainApp:TApplication); export; stdcall;
var
Child:TfrmMzgh;
begin
if not Assigned(SaveDllApp) then
begin
SaveDllApp:=Application;
Application:=MainApp;
end;
Child:=TfrmMzgh.Create(Application);
try
Child.Show;
except
child.free();
end;
end;
procedure MyLibraryProc(Reason:integer);
begin
if Reason=DLL_PROCESS_DETACH then
begin
if Assigned(SaveDllApp) then
Application:=SaveDllApp;
end;
end;
{$R *.res}
exports
showMdiChild;
begin
DLLProc := @MyLibraryProc;
end.
请帮助看一看。