Topic: A way to temporarily change a label.

Dear Everyone:

I have a procedure: example:

procedure Button_Recebido_tecnico_onClick (Sender: TObject; var Cancel: boolean);
begin
   ShowPainelTecnico;
   frm_assistencia.Button_Panel_Tecnico_Seguinte.Caption := 'Alterar';
   frm_assistencia.Button_Panel_Tecnico_Cancel.visible := false;
   frm_assistencia.Button_Panel_Tecnico_fechar.Visible := true;


end;

This will change the caption of a button , and hide / show two other buttons.
The problem is Next time i create another form (another ID etc...) the Changes on these buttons are still present.
The only wayt i can counter this is by manualy inserting a syntax like this:

   frm_assistencia.Button_Panel_Tecnico_Seguinte.Caption := 'Seguinte'; (THe default label on the button)
   frm_assistencia.Button_Panel_Tecnico_Cancel.visible := true; (the default visible status on the button)
   frm_assistencia.Button_Panel_Tecnico_fechar.Visible := false; (the default visible status on the button).

This is easy with just 3 components, but once you have a million things changing things start to become chaotic.

Is there a way to state something liike:

"Do Once per DB" or "Do once per trigger" ?

Re: A way to temporarily change a label.

I don't know if this is possible in MVD, but in Delphi you can have a separate unit that contains a record of all the buttons and labels for a form:

unit formstuff;

interface

TFormMainLabelsText = record
   Title,
   ButtonText,
   SomeText: string;
end;

implementation

Then in a View script/unit declare a class that has private calls to you the record, this allows you to alter and display on different forms just using one set of components.

unit viewform

interface

uses formstuff;

type
TMainFormLabels = class
private
   fMainFormLabels: TFormMainLabelsText;
public
  function GetLabelsText:TFormMainLabelsText;
  constructor Create;
  destructor Destroy; override;
end;

implementation

function TMainFormLabels.GetLabelsText: TFormMainLabelsText;
begin
  fMainFormLabels.Title:='Some Title';
  fMainFormLabels.ButtonText:=' This is a button';
  fMainFormsLabels.SomeText:= 'Some text';
  result:= fMainFormLabels;

In the main script/unit  you then reference the viewform and here you can then link the buttons and labels on a form to the ones n the formsstuff unit.

You create as many records as the text button types you need.

I've only used this sort of method once, as personally I find it very 'circular', but pure object programmers seem to love this kind of stuff, whereas I think procedural code is easier to follow and maintain. But, I'm not modern anymore sad

On a clear disk you can seek forever

Re: A way to temporarily change a label.

The problem is Next time i create another form (another ID etc...) the Changes on these buttons are still present.


Are you really creating a form for each record or do you mean simply storing the current record and reopen a form with clear fields?


Anyway, make a second procedure with the "Start setting" of the buttons and call it with the "on show" property of your form. To be sure, call it additional from the script or button (in this case maybe the on Click propery) when you store a record.


It is easier as the idea from CDB.

Re: A way to temporarily change a label.

teco049 wrote:

The problem is Next time i create another form (another ID etc...) the Changes on these buttons are still present.


Are you really creating a form for each record or do you mean simply storing the current record and reopen a form with clear fields?


Anyway, make a second procedure with the "Start setting" of the buttons and call it with the "on show" property of your form. To be sure, call it additional from the script or button (in this case maybe the on Click propery) when you store a record.


It is easier as the idea from CDB.

No, when i say create a new form i really only mean a new entry on the SQL Database, what i mean is whenever i create a newrecord or showrecord  that form that had been subjected to the changed made by the button is not "reseted" to their original values, but instead still hold the values that were true when i pressed the button