つづき
--------------------
unit DllMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DllUnit2;
type
TDllForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
DllForm: TDllForm;
implementation
{$R *.dfm}
procedure TDllForm.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TDllForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
if Assigned(DllSubForm) then DllSubForm.Release;
end;
end.
--------------------------
unit DllUnit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TDllSubForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
DllSubForm: TDllSubForm;
implementation
{$R *.dfm}
uses
DllMain;
procedure TDllSubForm.Button1Click(Sender: TObject);
begin
DllForm.Close;
end;
end.
--------------------
これで DllSubForm の Button1Click で両方閉じます。
|