procedure TFMainForm.SpeedButton2Click(Sender: TObject);
begin
   if activemdichild=FCarData then
       FCarData.append;       //FCarData为子窗口名,
                                append为定义在子窗口上的函数               
   if activemdichild=FSendCar then
       FSendCar.append;   end;我想把上边的写成一个过程
procedure TFMainForm.SpeedButton2Click(Sender: TObject);
begin
     app(FCarData);
     app(FSendCar);   
end;请问这个 app的过程应该怎样写,谢谢

解决方案 »

  1.   

    Procedure FCarData(Frm:TForm);
    begin
      FCarData.append;       
    end;
      

  2.   

    楼上误解我的意思了我问的是app这个函数应该怎么写procedure TFMainForm.app(Form:TForm);
    begin
        if activemdichild=Form then
             Form.append;
    end;错误提示:[Error] PMainForm.pas(230): Undeclared identifier: 'append'为什么会这样,应该怎样写
      

  3.   

    因为append是你在子窗体里自定义的方法,Tform里没有定义,如此调用当然编译不过。
    如果你硬要这么写的话,我想比较麻烦。得先写一个类,继承自Tform,加一个虚方法append,而你的子窗体又继承自这个类,在其中重载这个方法实现之。
    然后你的这个app就可以实现了,参数定义你自定义的那个类就可以了。
      

  4.   

    一定要这么写?那将就吧,程序有点烂:P
    procedure TFMainForm.app(Frm:TForm);
    begin
       if frm = FCarData then
       FCarData.Append;
       if frm = FSendCar then
       FSendCar.Append;
    end;
    procedure TFMainForm.SpeedButton2Click(Sender: TObject);
    begin
         app(FMainForm.ActiveMDIChild);
    end;
      

  5.   

    type
    pform=class(tform)
    produce tfmainform.app(form:tform);
    end;
    im......
    produce  pform.tfmation.app(form:tform)
    begin 
     if activemdichild=Form then
          Form.append;   
    end;
      

  6.   

    procedure TFMainForm.app(Sender: TObject);
    begin
      if ActiveMDIChild is TYourForm then
      begin
        (Sender as TYourForm).append;
      end;
    end;