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;
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;
Or you may actually want to use TLabel instead.
Related
I am adding a checkbox to my input query page to use it to show me the password uncovered, when is checked. But I don't know how to do that.
I already created the following procedure. But this procedure does not change me the true false value on add input. This procedure adds me new textbox that do the job.
Could you please help me?
procedure SPCheckBoxChecked(Sender: TObject);
begin
if Assigned(SPCheckBox) then
begin
if SPCheckBox.Checked then
CredentialsPage.Add('Password:', False)
if not SPCheckBox.Checked then
CredentialsPage.Add('Password:', True)
end;
end;
Use TPasswordEdit.Password property:
[Code]
var
InputQueryPage: TInputQueryWizardPage;
procedure ShowPasswordCheckClick(Sender: TObject);
begin
InputQueryPage.Edits[0].Password := not TNewCheckBox(Sender).Checked;
end;
procedure InitializeWizard();
var
ShowPasswordCheck: TNewCheckBox;
begin
InputQueryPage := CreateInputQueryPage(
wpWelcome, 'Password prompt', 'Please enter your password', '');
InputQueryPage.Add('Password:', True);
ShowPasswordCheck := TNewCheckBox.Create(WizardForm);
ShowPasswordCheck.Parent := InputQueryPage.Surface;
ShowPasswordCheck.Top :=
InputQueryPage.Edits[0].Top + InputQueryPage.Edits[0].Height + ScaleY(8);
ShowPasswordCheck.Height := ScaleY(ShowPasswordCheck.Height);
ShowPasswordCheck.Caption := '&Show password';
ShowPasswordCheck.OnClick := #ShowPasswordCheckClick;
end;
I would like to disable the "Next" button from my custom wizard page.
The fact is that I've no issue to change the caption of it for example, but if I set the NextButton.Enabled to False, Inno Setup show me the Welcome page instead of my Custom Page. Any Idea?
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.NextButton.Caption := 'test'; { Works }
WizardForm.NextButton.Enabled := false ; { delete my custom page }
WizardForm.CancelButton.Caption := 'Finish';
end;
procedure CreateTheWizardPages;
var
Page: TWizardPage;
TestConnectivityButton: TButton;
begin
Page := CreateCustomPage(wpWelcome, 'Connectivity Test', '');
CurPageChanged(Page.ID);
TestConnectivityButton := TButton.Create(Page);
TestConnectivityButton.Width := ScaleX(100);
TestConnectivityButton.Height := ScaleY(30);
TestConnectivityButton.Caption := CustomMessage('TestConnectivityAccessButtonLabel');
TestConnectivityButton.OnClick := #TestConnectivityWindow;
TestConnectivityButton.Parent := Page.Surface;
end;
procedure InitializeWizard;
begin
CreateTheWizardPages;
end;
You have to make the changes, when you enter your custom page only – When CurPageChanged event function is called with CurPageID equal to Page.ID.
And you cannot call CurPageChanged yourself!
var
Page: TWizardPage;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = Page.ID then
begin
WizardForm.NextButton.Caption := 'Test';
WizardForm.NextButton.Enabled := False ;
WizardForm.CancelButton.Caption := 'Finish';
end;
end;
procedure CreateTheWizardPages;
var
TestConnectivityButton: TButton;
begin
Page := CreateCustomPage(wpWelcome, 'Connectivity Test', '');
TestConnectivityButton := TButton.Create(Page);
TestConnectivityButton.Width := ScaleX(100);
TestConnectivityButton.Height := ScaleY(30);
TestConnectivityButton.Caption :=
CustomMessage('TestConnectivityAccessButtonLabel');
TestConnectivityButton.OnClick := #TestConnectivityWindow;
TestConnectivityButton.Parent := Page.Surface;
end;
Another option is using Page.OnActivate event instead of CurPageChanged event function.
My Inno Setup program have a custom "input file page" that was created using CreateInputFilePage.
How can I disable the NextButton in this page until the file path is properly picked by the user?
In other words, I need to make the NextButton unclickable while the file selection form is empty, and clickable when the file selection form is filled.
Thank you.
The easiest way is to use NextButtonClick to validate the inputs and display an error message when the validation fails.
var
FilePage: TInputFileWizardPage;
procedure InitializeWizard();
begin
FilePage := CreateInputFilePage(wpSelectDir, 'caption', 'description', 'sub caption');
FilePage.Add('prompt', '*.*', '.dat');
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if (CurPageID = FilePage.ID) and
(Length(FilePage.Edits[0].Text) = 0) then
begin
MsgBox('Please select a file.', mbError, MB_OK);
WizardForm.ActiveControl := FilePage.Edits[0];
Result := False;
end;
end;
If you really want to update the "Next" button state while the input changes, it is a bit more complicated:
procedure FilePageEditChange(Sender: TObject);
begin
WizardForm.NextButton.Enabled := (Length(TEdit(Sender).Text) > 0);
end;
procedure FilePageActivate(Sender: TWizardPage);
begin
FilePageEditChange(TInputFileWizardPage(Sender).Edits[0]);
end;
procedure InitializeWizard();
var
Page: TInputFileWizardPage;
Edit: TEdit;
begin
Page := CreateInputFilePage(wpSelectDir, 'caption', 'description', 'sub caption');
{ To update the Next button state when the page is entered }
Page.OnActivate := #FilePageActivate;
Edit := Page.Edits[Page.Add('prompt', '*.*', '.dat')];
{ To update the Next button state when the edit contents changes }
Edit.OnChange := #FilePageEditChange;
end;
I have created a custom welcome page with an image on it but the main panel on the top remains to be displayed. For what I want to achieve see image below:
Here is the code:
[Code]
procedure InitializeWizard;
var
BitmapFileName: string;
BitmapImage: TBitmapImage;
WelcomePage: TWizardPage;
begin
WelcomePage := CreateCustomPage(wpWelcome, '', '');
BitmapFileName := ExpandConstant('{tmp}\DataNova_Logo.bmp');
ExtractTemporaryFile(ExtractFileName(BitmapFileName));
BitmapImage := TBitmapImage.Create(WelcomePage);
BitmapImage.AutoSize := True;
BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
BitmapImage.Cursor := crHand;
BitmapImage.Left := 10;
BitmapImage.Top := 10;
BitmapImage.Parent := WelcomePage.Surface;
end;
How to show the image over the whole page with the main panel hidden ?
You need to hide the Bevel1, MainPanel and the InnerNotebook components when you switch to your welcome page and show them again when you leave it. As the opposite, the image you need to show only when you're showing your welcome page since it covers the whole page area. So the following code will do the trick:
[Code]
var
WelcomePageID: Integer;
BitmapImage: TBitmapImage;
procedure InitializeWizard;
var
WelcomePage: TWizardPage;
begin
WelcomePage := CreateCustomPage(wpWelcome, '', '');
WelcomePageID := WelcomePage.ID;
BitmapImage := TBitmapImage.Create(WizardForm);
BitmapImage.Bitmap.LoadFromFile('C:\Image.bmp');
BitmapImage.Top := 0;
BitmapImage.Left := 0;
BitmapImage.AutoSize := True;
BitmapImage.Cursor := crHand;
BitmapImage.Visible := False;
BitmapImage.Parent := WizardForm.InnerPage;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
BitmapImage.Visible := CurPageID = WelcomePageID;
WizardForm.Bevel1.Visible := CurPageID <> WelcomePageID;
WizardForm.MainPanel.Visible := CurPageID <> WelcomePageID;
WizardForm.InnerNotebook.Visible := CurPageID <> WelcomePageID;
end;
This is the code section from inno setup.My intention is to make two Checkbox where at a time one is being selected.
But this code return error when first checkbox is clicked.
[code]
procedure CheckBoxOnClick(Sender: TObject);
var
Box2,CheckBox: TNewCheckBox;
begin
if CheckBox.Checked then ///error:"Could not call proc" [sud it be global if then how to or what to change?]
BEGIN
CheckBox.State := cbUnchecked;
Box2.State := cbChecked;
END else
BEGIN
CheckBox.State := cbChecked;
Box2.State := cbUnchecked;
END;
end;
procedure Box2OnClick(Sender: TObject);
var
Box2,CheckBox: TNewCheckBox;
begin
if Box2.Checked then ///error:same
BEGIN
CheckBox.State := cbChecked;
Box2.State := cbUnchecked;
END else
BEGIN
CheckBox.State := cbUnchecked;
Box2.State := cbChecked;
END;
end;
procedure CreateTheWizardPages;
var
Page: TWizardPage;
Box2,CheckBox: TNewCheckBox;
begin
{ TButton and others }
Page := CreateCustomPage(wpWelcome, '', '');
CheckBox := TNewCheckBox.Create(Page);
CheckBox.Top :=ScaleY(8)+ScaleX(50);
CheckBox.Width := Page.SurfaceWidth;
CheckBox.Height := ScaleY(17);
CheckBox.Caption := 'Do this';
CheckBox.Checked := True;
CheckBox.OnClick := #CheckBoxOnClick;
CheckBox.Parent := Page.Surface;
Box2 := TNewCheckBox.Create(Page);
Box2.Top :=ScaleY(8)+ScaleX(70);
Box2.Width := Page.SurfaceWidth;
Box2.Height := ScaleY(17);
Box2.Caption := 'No,Thanks.';
Box2.Checked := False;
Box2.OnClick := #Box2OnClick;
Box2.Parent := Page.Surface;
end;
procedure InitializeWizard();
//var
begin
{ Custom wizard pages }
CreateTheWizardPages;
end;
Please tell me where to change..
The cause of your error is that your are referencing CheckBox which is defined locally in that method. At this point CheckBox has not been created. Which means your calling CheckBox.Checked when CheckBox is undefined (most likely NIL)
Each declaration of CheckBox represents a new variable and does not reference the other variables with the same name. This is due to scoping rules.
One option to solve your problem is to remove the local declarations of Box2, and CheckBox in each method and declare them globally.