当前位置:主页>销售管理软件> 列表

如何检测一个窗口已经关闭?

财务软件版1楼: 有2个窗体 Form1和Form2这是2个独立的程序。
我想实现这个功能
如果Form2关闭Form1也关闭

2楼: 在Form2的Close事件中写上Form1.Close; 如免费网吧管理软件

3楼: Form2我没有源码
只是别人写的程序
我想控制他

4楼: 搞一个timer检测,判断IsWindow(Handle)是否返回true。

5楼: 怎么搞有完整的代码吗?

6楼: 在Form2的Close事件中这样写:
var
a:hwnd;
begin
a:= FindWindow(nil,''Microsoft Access'');
if A<>0 then
SendMessage(a,WM_CLOSE,0,0);
end;
FindWindow 的第二个参数换成Form1的Caption.

财务软件版7楼: 加一个timer控件,代码如下:
TForm1.timer1Timer(sender:Tobject)
var
h:hwnd;
begin
h:=findwindow(''TForm2'',nil);
if h=0 then
self.close;
eend;

这样就OK了!

8楼: 多人接受答案了。