请问怎样才能隐藏mdi子窗体(100分)

默认行为就是隐藏
 
我是说创建后能在隐藏吗
 
试一下visible属性,前几天有人问过的!
 
早用过了不可能
 
不好隐藏.除非用api
你在onclose里面写action:=caFree;
self:=nil;吧
 
这样不就把窗体给关了吗里面的数据也没了
 
如果还想保留数据的话,
那么minimize岂不是更好理解一些,
按照一般的理解关闭了就应该释放了.
 
同意bubble的说法,不好隐藏,可以action:=caFree, self:=nil关闭,需要时打开。
 
最简单的办法是别把该窗体设为子窗体,
不然试一试透明窗体
 
给你一个变通的办法:
var
oldh,oldw : Integer;
oldc : String;

//隐藏MDI窗口
procedure TForm1.Button1Click(Sender: TObject);
begin
oldh := Form2.Height;
oldw := form2.Width;
oldc := Form2.Caption;
Form2.BorderStyle := bsNone;
Form2.FormStyle := fsNormal;
Form2.Height := 0;
Form2.Width := 0;
Form2.Caption := '';
end;

//显示窗口
procedure TForm1.Button2Click(Sender: TObject);
begin
Form2.BorderStyle := bsSizeable;
Form2.FormStyle := fsMDIChild;
Form2.Height := oldh;
Form2.Width := oldw;
Form2.Caption := oldc;
end;
 
Hiding a MDI child form will cirrupt the z-order of the child window, that is a well
knows flaw of MS windows implmentation of MDI. MS has no intentation to fix this bug
even they recently has a different way of approaching MDI in office 2000 or later.
Basically you have two way todo
so
1. Win32 API, LockWindowsUpdate(). You can use it to create a child windows but
not showing it untill some process has beendo
ne.
2. Win32 API ShowWindows() with SW_HIDE flag. You must then
use SetWindowPos() to
restor the child window. You can use this way to hide MDI child form if it is
already created and displayed to the user.
Good luck!
 
很简单嘛!两个API函数搞定!
eg: 如果要隐藏Form1
1。ShowWindow(Form1.handle,SW_HIDE);
如果要恢复
2。SetWindowPos(form1.handle,HWND_TOP,0,0,0,0,SWP_NOSIZE OR SWP_NOMOVE OR SWP_SHOWWINDOW);
 

Similar threads

D
回复
0
查看
739
DelphiTeacher的专栏
D
D
回复
0
查看
742
DelphiTeacher的专栏
D
D
回复
0
查看
590
DelphiTeacher的专栏
D
顶部