2

How can I capture changes in text box value?

I'm researching how to use OnChange event function but i don't know how to use it.

[Code]
var
  Page: TInputQueryWizardPage;

procedure InitializeWizard();
begin
  Page := CreateInputQueryPage(wpWelcome,
    'Personal Information', 'Who are you?',
    'Please specify your name and the company for whom you work, then click Next.');

  Page.Add('Server:', False);
  Page.Add('NAME:', False);
  Page.Add('LOCATION:', False);

  Page.Values[0] := ('test0');
  Page.Values[1] := ('test1');
  Page.Values[2] :=  ('string')+Page.Values[0]+('string')+Page.Values[1];
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • So you want to alter text of one (2) edit box, as text of other edit boxes (0 and 1) is being changed by the user? What if the user changes text of 2? Or will you make 2 read-only? – Martin Prikryl Mar 13 '18 at 09:41
  • i need to alter all of texts to compose command – Andrea Artoni Mar 13 '18 at 09:49
  • Sorry, but this is totally unclear. What command? Where/how do you want to use the command? – Martin Prikryl Mar 13 '18 at 09:54
  • i need to run a cmd command and it is composed by Page.Values0+1+2+3 . i need to input text and finally run command using run section or with button . (button is the alternative ) – Andrea Artoni Mar 13 '18 at 10:02
  • sorry but my question is not how to pass variable into run. in my code if i input a text into Page.Values[0] then Page.Values[2] not change. – Andrea Artoni Mar 13 '18 at 10:48
  • Your comments contradict each other. So maybe you really need to carefully read my very first question and answer it correctly. – Martin Prikryl Mar 13 '18 at 10:55
  • sorry Martin Prikryl but is not easy for me to explain in english. i read again your first question and your interpretation is correct. if text of 2 is read only is better but in this moment i'm try to learn how to alter text of 2 . i hope now is more clear and sorry again for my bad english – Andrea Artoni Mar 13 '18 at 11:03
  • See my answer... – Martin Prikryl Mar 13 '18 at 11:07

1 Answers1

1

Handle OnChange event like:

var
  Page: TInputQueryWizardPage;

procedure EditChange(Sender: TObject);
begin
  Page.Values[2] := 'string' + Page.Values[0] + 'string' + Page.Values[1];
end;

procedure InitializeWizard();
begin
  Page := CreateInputQueryPage(...);

  Page.Add('Server:', False);
  Page.Add('NAME:', False);
  Page.Add('LOCATION:', False);

  Page.Values[0] := 'test0';
  Page.Values[1] := 'test1';

  Page.Edits[0].OnChange := @EditChange;
  Page.Edits[1].OnChange := @EditChange;
  { Reflect the initial values }
  EditChange(nil);
end;

Note that the Edit[2] can be changed by the user, so maybe you want to set it read only.

  Page.Edits[2].ReadOnly := True;
  Page.Edits[2].Color := clBtnFace;

enter image description here

Or you may actually want to use TLabel instead.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992