对没考虑mouse会移到子窗体的控件上
改了一下
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
private
{ Private declarations }
procedure cmmouseleave(var msg:Tmessage);message cm_mouseleave;
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.cmmouseleave(var msg: Tmessage);
var tp:Tpoint;
h:Thandle;
begin
getcursorpos(tp);
h:=windowfrompoint(tp);
if h=form1.Handle then
sendmessage(handle,wm_close,0,0)
end;
end.