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.
Related
How can I make a button or a text in the Inno Setup installer that opens a web page when clicked?
To open a webpage, use:
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
See also How to show a hyperlink in Inno Setup?
To link this with a button, use:
procedure ButtonClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
Button: TButton;
begin
Button := TButton.Create(WizardForm);
Button.Parent := WizardForm;
Button.Left := ScaleX(16);
Button.Top := WizardForm.NextButton.Top;
Button.Width := WizardForm.NextButton.Width;
Button.Height := WizardForm.NextButton.Height;
Button.Caption := 'Link';
Button.OnClick := #ButtonClick;
end;
To link this with a label, use:
procedure LinkLabelClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
LinkLabel: TLabel;
begin
LinkLabel := TLabel.Create(WizardForm);
LinkLabel.Parent := WizardForm;
LinkLabel.Left := ScaleX(16);
LinkLabel.Top :=
WizardForm.NextButton.Top + (WizardForm.NextButton.Height div 2) -
(LinkLabel.Height div 2);
LinkLabel.Caption := 'Link';
LinkLabel.ParentFont := True;
LinkLabel.Font.Style := LinkLabel.Font.Style + [fsUnderline];
LinkLabel.Font.Color := clBlue;
LinkLabel.Cursor := crHand;
LinkLabel.OnClick := #LinkLabelClick;
end;
How can I make a button or a text in the Inno Setup installer that opens a web page when clicked?
To open a webpage, use:
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
See also How to show a hyperlink in Inno Setup?
To link this with a button, use:
procedure ButtonClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
Button: TButton;
begin
Button := TButton.Create(WizardForm);
Button.Parent := WizardForm;
Button.Left := ScaleX(16);
Button.Top := WizardForm.NextButton.Top;
Button.Width := WizardForm.NextButton.Width;
Button.Height := WizardForm.NextButton.Height;
Button.Caption := 'Link';
Button.OnClick := #ButtonClick;
end;
To link this with a label, use:
procedure LinkLabelClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
LinkLabel: TLabel;
begin
LinkLabel := TLabel.Create(WizardForm);
LinkLabel.Parent := WizardForm;
LinkLabel.Left := ScaleX(16);
LinkLabel.Top :=
WizardForm.NextButton.Top + (WizardForm.NextButton.Height div 2) -
(LinkLabel.Height div 2);
LinkLabel.Caption := 'Link';
LinkLabel.ParentFont := True;
LinkLabel.Font.Style := LinkLabel.Font.Style + [fsUnderline];
LinkLabel.Font.Color := clBlue;
LinkLabel.Cursor := crHand;
LinkLabel.OnClick := #LinkLabelClick;
end;
Friends like I do this script text appears only on page "wpselectTasks"
Replacing wpSelectDir to wpSelectTasks
Inno setup compile but nothing appears on the page "wpselectTasks"
Using wpSelectDir will be normal.
**(thus appears on the page wpSelectDir)**
var
avisoLabel: TLabel;
procedure InitializeWizard();
var
aviso: TLabel;
begin
avisoLabel := TLabel.Create(WizardForm);
avisoLabel.Left := ScaleX(0);
avisoLabel.Top := ScaleY(190)
avisoLabel.Width := ScaleY(185)
avisoLabel.Height := ScaleY(13)
avisoLabel.Parent:= WizardForm.SelectDirPage;
avisoLabel.Transparent:=true;
avisoLabel.Caption := 'OBS: Sem estes programas instalados o jogo não inicia';
//avisoLabel.AutoSize := True;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
avisoLabel.Visible := CurPageID = wpSelectDir;
end;
**(modifying for wpSelectTasks nothing appears)**
var
avisoLabel: TLabel;
procedure InitializeWizard();
var
aviso: TLabel;
begin
avisoLabel := TLabel.Create(WizardForm);
avisoLabel.Left := ScaleX(0);
avisoLabel.Top := ScaleY(190)
avisoLabel.Width := ScaleY(185)
avisoLabel.Height := ScaleY(13)
avisoLabel.Parent:= WizardForm.SelectTasksPage;
avisoLabel.Transparent:=true;
avisoLabel.Caption := 'OBS: Sem estes programas instalados o jogo não inicia';
//avisoLabel.AutoSize := True;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
avisoLabel.Visible := CurPageID = wpSelectTasks;
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.