DuckQueen
DuckQueen

Reputation: 810

How to jump to page on on button click?

I need a simple thing: have advance and normal installation buttons. For normal case it is all simple - I used default next button with some logic on NextButtonClick to set a condition variable and skeep some pages using ShouldSkipPage . Yet for advanced setup I created a new button and all I need it to do on click is to open next installer page:

procedure CurPageChanged(CurPageID : Integer);
begin
if CurPageID = wpWelcome then begin
    AdvancedButton := TButton.Create(WizardForm);
    AdvancedButton.Caption := 'Advanced Install';
    AdvancedButton.Left := WizardForm.InfoAfterPage.Left + 10;
    AdvancedButton.Top := WizardForm.InfoAfterPage.Height + 88;
    AdvancedButton.Parent := WizardForm.NextButton.Parent;
    # AdvancedButton.OnClick :=  What shall I call to open say next page (or some page by given PageID value)
    end
    else begin
    AdvancedButton.Visible := False;
    end;

end;

So What shall I call to open say next page (or some page by given PageID value) on my button click (could not find any NextPage or some SetPage function in Inno API)?

Upvotes: 2

Views: 1855

Answers (2)

Dragodraki
Dragodraki

Reputation: 53

WizardForm.NextButton.OnClick(nil); isn't recommend as it takes the maximum page you ever opened. Usually its the same as your page shows, but if you manipulate their order, it differs!

As for the build-in pages, there exist always two different names - the ID one and the code-equivalent. Look at this page https://jrsoftware.org/ishelp/index.php?topic=wizardpages and append the word "Page", leaving out all the spaces.

E.g.: wpSelectTasks = SelectTasksPage

procedure SettingsChangeButtonOnClick(Sender: TObject);
begin
  WizardForm.SelectTasksPage.Show;
end;

procedure CreateTheWizardPages;
var
  SettingsChangeButton: TButton;
begin
  CustomPage1 := CreateCustomPage(wpSelectTasks, CustomMessage('CustomTitle'), CustomMessage('CustomSubTitle'));
  SettingsChangeButton := TButton.Create(CustomPage1);
  SettingsChangeButton.OnClick := @SettingsChangeButtonOnClick;
end;

procedure InitializeWizard;
begin
  CreateTheWizardPages;
end;

Especially the line: WizardForm.SelectTasksPage.Show; should be changed to the page you would jump to. If you have a custom page or you want +1 page, just use PostMessage(WizardForm.NextButton.Handle, 245,0,0); and -1 with PostMessage(WizardForm.BackButton.Handle, 245,0,0); PostMessage actually does the same job as if you click the button with the mouse, not to compare with SendMessage or OnClick(nil).

It doesn't matter, whether the site is skipped by default. If you call it like this, it will be visible. Just keep in mind, always testing your installer, as manipulating the order of pages might result in unwanted site effects such as errors or endless loops.

Upvotes: 0

Slappy
Slappy

Reputation: 5472

There is no such thing as "Direct jump to page" in Inno Setup. All you need is to quietly skip certain pages in 'Advanced mode'.

Simply do the same as in regular installer. Set one variable for holding 'Advanced mode'. After clicking the Advance button:

[Code]
var
  IsAdvanced: Boolean;

procedure AdvancedButtonClick(Sender: TObject);
begin
  IsAdvanced := True;
  WizardForm.NextButton.OnClick(nil);
end;

procedure InitializeWizard;
var
  AdvancedButton: TNewButton;
begin
  // not necessary; just for sure
  IsAdvanced := False;
  // create the button
  AdvancedButton := TNewButton.Create(WizardForm);
  AdvancedButton.Caption := 'Advanced Install';
  AdvancedButton.Left := WizardForm.InfoAfterPage.Left + 10;
  AdvancedButton.Top := WizardForm.InfoAfterPage.Height + 88;
  AdvancedButton.Parent := WizardForm.NextButton.Parent;
  AdvancedButton.OnClick := @AdvancedButtonClick;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // the <page where you want to end up> fill with the wizard page constant
  // of the page where you want to end up, e.g. wpReady
  Result := IsAdvanced and (PageID <> <page where you want to end up>);
end;

With this logic you can simulate quiet 'jump' to certain page.

Upvotes: 1

Related Questions