unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm_MDIChild = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
protected
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
Form_MDIChild: TForm_MDIChild;
implementation
{$R *.dfm}
procedure TForm_MDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//关闭时将窗口隐藏
WindowState := wsMinimized;
ShowWindow(Handle, SW_HIDE);
//Action = caFree; //关闭时释放
end;
procedure TForm_MDIChild.WndProc(var Message: TMessage);
begin
inherited;
//最小化时将窗口隐藏
if (Message.Msg = WM_SYSCOMMAND) and (Message.WParam = SC_MINIMIZE) then
ShowWindow(Handle, SW_HIDE);
end;
end.
重新显示子窗口:
ShowWindow(Form_MDIChild.Handle, SW_RESTORE);