在MDI环境中如何打开一个子窗口,打开后如何关闭它?请给出源码,正确者,一百分全给他.
解决方案 »
- delphi7单击DBGRID表中的某一行的数据时,就会显示在另外一个窗体上
- 关于Treeview读取配置文件
- 如何查找出某个表的自增长字段,且可以前台程序删除和新增,在不知道名称的情况下?
- QReport打印多份时,如何记录打印份数的序号??
- 很奇怪的问题,大家都来看一下啊 100相送
- 最小化窗体时我要执行一段操作,不知道怎么实现?
- 钱太多,过年了,就送点压岁钱吧!
- 如何取得浏览器内用鼠标选中的文本,用webbrowser控件
- 怎样把Ehlib24的TDBGridEh的抬头变中文?
- DBGrid显示Access库中TEXT型数据时只能看到(MEMO)
- 求助!如何读取delphi编译时自动产生的文本号?
- 谁用过MSFlexGrid控件,100分相送?
var
i: integer;
Child:TForm;
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms[i].ClassType=FormClass then
begin
Child:=Screen.Forms[i];
if Child.WindowState=wsMinimized then
ShowWindow(Child.handle,SW_SHOWNORMAL)
else
ShowWindow(Child.handle,SW_SHOWNA);
if (not Child.Visible) then Child.Visible:=True;
Child.BringToFront;
Child.Setfocus;
TForm(fm):=Child;
exit;
end;
Child:=TForm(FormClass.NewInstance);
TForm(fm):=Child;
Child.Create(AOwner);
end;这样你每次调用即可:如: OpenForm(TfrmChild1,frmChild1, self);别忘了在close的时候: Action:=caFree;
action:=cafree;
begin
close;
end;procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if mdichildcount>0 then
begin
activemdichild.Close;
end;
Application.CreateForm(TForm2,Form2);
form2.Show;
end;
在子窗体的关闭事件里写上
action:=cafree;
这样功能就实现了
在打开一个另一个子窗体的同时前一个子窗体自动就关闭了
renzhm(戴尔飞) 的代码是经典.