ShouldSkipPage is called twice per page

社会主义新天地 提交于 2020-05-23 11:12:30

问题


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?


回答1:


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:



来源:https://stackoverflow.com/questions/40991601/shouldskippage-is-called-twice-per-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!