如何在子窗体关闭的同时关闭主窗体 主窗体form1手动产生了子窗体form2,然后form1.hide,form2.showform2在关闭的时候需要关闭form1,这个功能怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Form2的OnClose事件中添加如下代码:Application.Terminate; 在FORM2的OnCloseQuery事件中写上:Form1.Close; procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);begin Form1.Close;end; 那在form1关闭的时候,form2会完全释放么?不需要自己写form2.free么? Form2 := TForm2.Create(Application);就可以不用手工释放了 可以用消息来实现在主窗体先自定义一个消息 主窗体的代码:unit Unit4;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;const WM_MY_CLOSE = WM_USER + 1234;type TFormMain = class(TForm) private { Private declarations } procedure MY_CLOSE(var msg: TMSG); message WM_MY_CLOSE; public { Public declarations } end;var FormMain: TFormMain;implementation{$R *.dfm}{ TFormMain }procedure TFormMain.MY_CLOSE(var msg: TMSG);begin Application.Terminate;end;end.然后发送消息 PostMessage(FormMain.Handle, WM_USER + 1234, 0, 0) 动态生成的panel如何写事件代码 关于WEBSERVICE中服务接口代码变化的问题 delphi如何实现自删除? 熟悉cxGrid的进来 控件高手请进:明明编译通过的控件,为什么使用的时候工程文件提示找不到DesignIntf.dcu wks 帐龄的分析问题,有兴趣的朋友进来看看好了。 刚下了一个例子,dao+access,打不开access2k的数据库?access97ok 说说Delphi2009对备注型字段的处理方式(解决大家备注字段截断的问题) 急!关于EXCEL打印行数的设置 有没有自动实现小记合计的数据库控件 DELPHI中如何判断一个DLL已经运行?
Application.Terminate;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.Close;
end;
不需要自己写form2.free么?
在主窗体先自定义一个消息 主窗体的代码:
unit Unit4;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;const
WM_MY_CLOSE = WM_USER + 1234;type
TFormMain = class(TForm)
private
{ Private declarations }
procedure MY_CLOSE(var msg: TMSG); message WM_MY_CLOSE;
public
{ Public declarations }
end;var
FormMain: TFormMain;implementation{$R *.dfm}{ TFormMain }procedure TFormMain.MY_CLOSE(var msg: TMSG);
begin
Application.Terminate;
end;end.
然后发送消息 PostMessage(FormMain.Handle, WM_USER + 1234, 0, 0)