我现在写了一个主窗口。
后来做了一个子窗口。
我想点菜单中的一项来启动子窗口。应如何写?

解决方案 »

  1.   

    Form2为子窗的Name,下面的代码写在启动子窗的按钮里面:
       Form2:=TForm2.Create(self);
       Form2.showmodal;
      

  2.   

    假设你的主窗口是Form1,对应的文件是Unit1.pas
    假设你的子窗口是Form2,对应的文件是Unit2.pas在Unit1中Interface或Implementation下写 uses unit2;然后在菜单的动作中写
     Form2.Show; //非模态显示
    或 Form2.ShowModal; //模态显示
      

  3.   

    不行呀!提示“没有定认about”
    子窗口名为about
      

  4.   

    搞好了。原来我增加的是一个box
    aboutbox.show;就可以了。
      

  5.   

    在Unit1中Interface或Implementation下写 uses unit2;然后在菜单的动作中写
    if not assigned(form2) then
       application.createform(Tform2,form2);
     Form2.Show; //非模态显示
    或 Form2.ShowModal; //模态显示同时在form2的ondestory 事件中写下:
    action:=cafree;
    form2:=nil;
      

  6.   

    if not assigned(aboutbox) then
    begin
     aboutbox:=Taboutbox.Create(Application);
     aboutbox.show; // or ShowModal;
    end
    else
     aboutbox.show; // or ShowModal;onclose事件:
      aboutbox:=nil;
      action:=caFree;