看这个合不合你用吧
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs;
type
TForm3 = class(TForm)
private
{ Private declarations }
protected
procedure CreateWindowHandle(const Params: TCreateParams);
override;
procedure DestroyWindowHandle;
override;
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit2, Consts;
{$R *.DFM}
procedure TForm3.CreateWindowHandle(const Params: TCreateParams);
var
CreateStruct: TMDICreateStruct;
begin
if (FormStyle = fsMDIChild) and not (csDesigning in
ComponentState) then
begin
if (Form2 = nil) or (Form2.ClientHandle = 0)
then
raise EInvalidOperation.CreateRes(SNoMDIForm);
with CreateStructdo
begin
szClass := Params.WinClassName;
szTitle := Params.Caption;
hOwner := HInstance;
X := Params.X;
Y := Params.Y;
cX := Params.Width;
cY := Params.Height;
style := Params.Style;
lParam := Longint(Params.Param);
end;
WindowHandle := SendMessage(Form2.ClientHandle,
WM_MDICREATE, 0, Longint(@CreateStruct));
//Include(FFormState, fsCreatedMDIChild);
end else
inherited CreateWindowHandle(Params);
end;
procedure TForm3.DestroyWindowHandle;
begin
SendMessage(Form2.ClientHandle, WM_MDIDESTROY, Handle, 0);
inherited DestroyWindowHandle;
end;
end.