Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
788 views
in Technique[技术] by (71.8m points)

inno setup - ShouldSkipPage is called twice per page

I've noticed, that ShouldSkipPage is called twice per each page - before page is actually shown, and after. You can easily check this, by simply adding Log to function:

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  if  PageID = wpSelectDir then
    Log('ShouldSkipPage for SelectDir was called');

  Result := false;
end;

You will see logged message twice (and by executing script in compiler, you can see, that second call occurs after page was shown).

So, can someone explain, why it is called second time, already after page was shown? This makes no sense, and may be confusing and even lead to unexpected deviations in installer logic.

Also, is there any way to prevent second call?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The first call (or actually the first set of calls) is to find the next page to display.

The second call (or actually the second set of calls) is to find, if there's any page to return to (to decide if the Back button should be visible).

This way you can e.g. prevent a user to return back once a certain page is reached.

In general the ShouldSkipPage event function could be called any number of times and at any time. And your code must be able to handle that.

If you want to do special processing before and after a page is changed, use the NextButtonClick/BackButtonClick and the CurPageChanged, not the ShouldSkipPage.


The following example shows, how to prevent a user from modifying an installation, once the "Ready to Install" page is reached:

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;

  if (WizardForm.CurPageID >= wpReady) and (PageID < wpReady) then
  begin
    Result := True;
  end;
end;

There won't be any Back button on the "Ready to Install" page:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...