In an Inno Setup installer, I need a separate custom button to mimic the behavior of clicking the next button, is their a function I can apply to the OnClick handler of the custom button to do this?
You can trigger the next button's OnClick event manually for instance this way (the only parameter here is the Sender, which is usually the object which triggered the event, but in the original next button click event handler is this parameter ignored, so let's pass an empty, nil object there):
WizardForm.NextButton.OnClick(nil);
So the rest is about creating your own button and calling a code like above to mimic the next button click, for example:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
procedure MyNextButtonClick(Sender: TObject);
begin
WizardForm.NextButton.OnClick(nil);
end;
procedure InitializeWizard;
var
MyNextButton: TNewButton;
begin
MyNextButton := TNewButton.Create(WizardForm);
MyNextButton.Parent := WizardForm;
MyNextButton.Left := 10;
MyNextButton.Top := WizardForm.NextButton.Top;
MyNextButton.Caption := 'Click me!';
MyNextButton.OnClick := #MyNextButtonClick;
end;
Related
I'm stuck on simple situation with OnClickCheck property. The problem is that I see a Msgbox every time I turn on backup task, but also (while it's switched on) OnClickCheckappeared on pressing uninst task too! Seems that OnClickCheck checks all clicks, but I need to check click only on the first task.
It is logical to add to "WizardForm.TasksList.OnClickCheck" exact number of task (WizardForm.TasksList.OnClickCheck[0]), but compiler doesn't agree with it.
[Tasks]
Name: backup; Description: do backup
Name: uninst; Description: do not create uninstaller
[Code]
procedure TaskOnClick(Sender: TObject);
begin
if IsTaskSelected('backup') then
begin
MsgBox('backup task has been checked.', mbInformation, MB_OK)
end;
end;
procedure InitializeWizard();
begin
WizardForm.TasksList.OnClickCheck := #TaskOnClick;
end;
There's no way tell exactly what task (list item) was changed in the OnClickCheck event.
To tell which item was checked by the user, you can use the ItemIndex property. The user can check only the selected item.
Though if you have a task hierarchy, even unselected task can be toggled automatically by the installer due to a change in child/parent items. So to tell all changes, all you can do is to remember the previous state and compare it against the current state, when the OnClickCheck is called.
var
TasksState: array of TCheckBoxState;
procedure TasksClickCheck(Sender: TObject);
var
I: Integer;
begin
for I := 0 to WizardForm.TasksList.Items.Count - 1 do
begin
if TasksState[I] <> WizardForm.TasksList.State[I] then
begin
Log(Format('Task %d state changed from %d to %d',
[I, TasksState[I], WizardForm.TasksList.State[I]]));
TasksState[I] := WizardForm.TasksList.State[I];
end;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
I: Integer;
begin
if CurPageID = wpSelectTasks then
begin
{ Only now is the task list initialized (e.g. based on selected setup }
{ type and components). Remember what is the current/initial state. }
SetArrayLength(TasksState, WizardForm.TasksList.Items.Count);
for I := 0 to WizardForm.TasksList.Items.Count - 1 do
TasksState[I] := WizardForm.TasksList.State[I];
end;
end;
procedure InitializeWizard();
begin
WizardForm.TasksList.OnClickCheck := #TasksClickCheck;
end;
Instead of using indexes, you can also use task names with use of WizardSelectedTasks or WizardIsTaskSelected. For an example, see Inno Setup: how to auto select a component if another component is selected?
Also see:
Inno Setup ComponentsList OnClick event
Inno Setup Uncheck a task when another task is checked
Inno Setup - Show children component as sibling and show check instead of square in checkbox
I'm using the code from:
http://www.jrsoftware.org/ishelp/index.php?topic=setup_disablereadypage
It should change the Next button caption to Install when the "Ready" page is disabled using DisableReadyPage directive.
[Setup]
DisableReadyPage=yes
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectProgramGroup then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
But it does not change Next button caption.
As the description of the code says:
For example, if the new last pre-installation wizard page is the Select Program Group page: ...
In your case the last pre-installation page is not Select Program Group page. It's the Select Destination Location page. Probably because you have DisableProgramGroupPage set to no, or you have set it to auto and you are upgrading (the application is installed already).
If you have the DisableProgramGroupPage set to no, the solution is simple, as the Select Destination Location page is always the last. Just replace the wpSelectProgramGroup with wpSelectDir.
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
With auto (the default), you do not get any of Select Program Group and Select Destination Location on upgrade, but you get the Ready to Install even with DisableProgramGroupPage (as there would not be any other page before installation). You can use that fact to use Install both for Select Program Group page (for fresh installs) and Ready to Install (for upgrades).
Another issue with their code is that you should get a Finish button on the "Finished" page (wpFinished). What their code does not care for.
The complete solution is:
procedure CurPageChanged(CurPageID: Integer);
begin
// On fresh install the last pre-install page is "Select Program Group".
// On upgrade the last pre-install page is "Read to Install"
// (forced even with DisableReadyPage)
if (CurPageID = wpSelectProgramGroup) or (CurPageID = wpReady) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
// On the Finished page, use "Finish" caption.
else if (CurPageID = wpFinished) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
// On all other pages, use "Next" caption.
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
Had you have other pages, like Tasks page, you would have to alter the code accordingly.
Your screenshot shows the wpSelectDir page while in your code you change the button of the wpSelectProgramGroup page.
I am completely new to inno setup.
I have an existing inno setup code which loads all the pages in the InitializeWizard(). I am trying to change the caption dynamically in the next page based on the radio button selected in the previous page.
ExpandConstant('Special note for the Microsoft ' + SelectedSQLServerVersion + ' Setup')
Here the SelectedSQLServerVersion is a variable which holds the dynamic value from the previous page and I can see the value in log. I tried to load the page again and was expecting the variable will be replaced with the dynamic value in the second time, but it was empty. Is there any way to solve this.
Thanks in advance,
DeeJay
Wizard pages have two common properties for the top bar labels, Caption and Description. In your case you can update them e.g. when the page is just displayed, from the CurPageChanged event:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
var
MyPage: TWizardPage;
procedure InitializeWizard;
begin
MyPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = MyPage.ID then
begin
MyPage.Caption := 'New caption';
MyPage.Description := 'New description';
end;
end;
I am aware that it is possible to disable (so it appears dimmed) the Back button on a Wizard Page using the following code:
procedure CurPageChanged(CurPageID: Integer);
begin
//Define whether the Back button is enabled
if CurPageID = UnlockCodePage.ID then
begin
WizardForm.BackButton.Enabled := False;
end;
end;
However, is there a way to actually completely remove/hide the Back button so that it can't be seen at all?
You should be able to use the Button.Visible property:
if CurPageID = UnlockCodePage.ID then
WizardForm.BackButton.Visible := False;
so i am currently trying to modify the setup script,
What i was trying to do was after installing i enter in a custom page, this custom page executes 2 scritps(one for creating the database and the other for creating the tables).
while this is executing i want to display a custom label,and a continuous progress bar.
When the execution finish, i want to go directly to the finish page.
I wanto to also remove the next button.
Is this possible?
For the moment i have the custom page with a constinuous progress bar, this page appears after install.i will then add the label after finishing the progress bar part.
here is my code:
[CODE]
var
Page: TWizardPage;
ProgressBar3: TNewProgressBar;
procedure CreateTheWizardPages;
begin
Page := CreateCustomPage(wpInstalling, 'Base de dados', 'A verificar a base de dados');
ProgressBar3 := TNewProgressBar.Create(Page);
ProgressBar3.Left := 5;
ProgressBar3.Width := Page.SurfaceWidth - 5;
ProgressBar3.Parent := Page.Surface;
ProgressBar3.Style := npbstMarquee;
end;
procedure InitializeWizard();
begin
CreateTheWizardPages;
end;
//check the current page,if page equals to wpSelectCompnets, then we add the method on choose to the combobox fo types of installation
procedure CurPageChanged(CurPageID: Integer);
begin
//msgbox(IntToStr( CurPageID),mbInformation, MB_OK);
if CurPageID = wpSelectComponents then
begin
comboboxTypesInstalacao:=WizardForm.TypesCombo;
WizardForm.TypesCombo.OnChange:=#ComboBoxChange;
end
else if CurPageID = Page.ID then
begin
try
CreateDBAndTables('idontimedb.des');
finally
//close this custom wizard page and go to finish page
end;
end;
end;
Thanks in advance.