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的过程应该怎样写,谢谢
begin
FCarData.append;
end;
begin
if activemdichild=Form then
Form.append;
end;错误提示:[Error] PMainForm.pas(230): Undeclared identifier: 'append'为什么会这样,应该怎样写
如果你硬要这么写的话,我想比较麻烦。得先写一个类,继承自Tform,加一个虚方法append,而你的子窗体又继承自这个类,在其中重载这个方法实现之。
然后你的这个app就可以实现了,参数定义你自定义的那个类就可以了。
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;
pform=class(tform)
produce tfmainform.app(form:tform);
end;
im......
produce pform.tfmation.app(form:tform)
begin
if activemdichild=Form then
Form.append;
end;
begin
if ActiveMDIChild is TYourForm then
begin
(Sender as TYourForm).append;
end;
end;