var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
//把Form2的Parent改为Form1
Form2 := TForm2.CreateParented(Form1.Handle);
Form2.Show;
//使得Form2处于激活状态
SendMessage(Form2.Handle, WM_NCACTIVATE, Ord(True), 0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form2.Close;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
//记得加上这一句
if Form2.Showing then Form2.Close;
end;
end.
上面的代码就可以显示一个与Form1同处激活状态的Form2,再对Form2的BorderStyle与BorderIcons属性作一些必要的选择,就可以实现更加完美的效果!
本文地址:http://com.8s8s.com/it/it4287.htm