procedure TForm1.menu1Click(Sender: TObject);
var
childform:TForm2;
begin
if mdichildcount=1 then
previous
else
begin
ChildForm:=TForm2.Create(Application);
childform.show;
end;
既然你只想开一个窗口,那么,在主窗口中
设定一个变量:
public:
MDIForm:TMDIChild;
procedure TForm1.menu1Click(Sender: TObject);
begin
if mdichildcount=1 then
MDIForm.Show;
else
begin
MDIForm:=TMDIChild.Create(Self);
MDIform.show;
end;
end;
Charles: 我确实输入正确的参数,奇怪!!??
不过我想了一个苯办法,基本达到了我的目的
var
i,bz : Integer
begin
Bz := 0;
For i := 0 To MDIChildrenCount-1do
if MDIChildren.name='myformname' then
begin
MDIChildren.BringToFront;
Bz := 1;
The <strong>FindWindow</strong> function retrieves the handle to the top-level window
whose class name and window name match the specified strings. <strong>This
functiondo
es not search child windows.</strong>
The <strong>FindWindowEx</strong> function retrieves the handle to a window whose
class name and window name match the specified strings. <strong>The function
searches child windows</strong>, begin
ning with the one following the given
child window.
>>同一个MDI CHILD窗口可以开多个,
>>但我只想开一个,如果再开只把原来已经开的窗体显示出来
你不是说只想开一个吗?如果我不是理解错的话,那就是说你的
MDIForm有很多种了,每一种只想开一个?
那就用下面的方法:
procedure TMainForm.NewMyFormClick(Sender:TObject);
var
i : Integer
begin
For i := 0 To MDIChildCount-1do
if MDIChildren is TMyForm then