How to call a procedure from the inherited form through the standard form?

0

In my Delphi 7 application, some Runtime objects are created in the default form, such as buttons to handle registry, procedures, and common functions. There is one standard form of queries, another for editing records and one for reports. The standard form of record editing has the procedure "Save", it has the following:

//Evento Salvar de FrmPadraoEdit
procedure TFrmPadraoEdit.Salvar(Sender: TObject);
begin
  ToolBar.Setfocus;
  //Demais instruções

  //deve continuar para a procedure Salvar do form herdado
end;

As the "btnSave" button is also on the default form, the "Save" event is already assigned to it.

It turns out that for each inherited form, the "Save" event has different instructions. In the standard form, after calling the "Save" event of itself, you can continue with the instructions in the "Save" event of the inherited form? For example:

//Evento Salvar de FrmDisciplinasEdit
procedure TFrmDisciplinasEdit.Salvar(Sender: TObject);
begin
  //Aqui deveria continuar a execução

  DM.cdsDisciplinasATIVO.Value := 1;
  DM.cdsDisciplinasCREATED_BY.Value := V_LOGIN;
  //Demais instruções...
  DM.cdsDisciplinas.Post;
  Close;
end;
    
asked by anonymous 26.04.2018 / 21:49

1 answer

2

I do not know how you are defining these events, but an easy solution was to get the code from the click of the buttons and by your method. In the default form declared

procedure DoSave; virtual;

With the code you need to call in the standard and call this in the click of the button

In inherited forms I declared this method

procedure DoSave; override;

and within this the code you wanted for each inherited form. To call the standard code I used the inherited. Something like

procedure TFormHerdado.DoSave();
begin
   //Chamar save do form padrao
   inherited;
   //Codigo do form herdado
end
    
26.04.2018 / 23:27