使用inno-setup在安装过程中显示文本

时间:2015-01-15 15:01:26

标签: inno-setup

我正在寻找向用户显示如何在安装可再发行组件期间继续操作的说明。

背景: 我有一些组件需要第三方安装,退出复杂。如果用户选择这些组件之一,则显示带有指令的消息框。在此框之后,抵抗组合是通过exec / shellExec和'ewWaitUntilTerminated'执行的。不幸的是,用户在安装过程中无法看到该框。

我试图在记事本中打开笔记并使用'ewNoWait',但是每次安装redistributalbe后它都不会自动关闭。用户可以选择多个这些组件,只有在特定安装过程中才能看到此帮助。要使用taskkill杀死记事本不是一个选项,它可能会杀死用户打开的记事本。

有没有优雅的方式来获得这样的行为?

2 个答案:

答案 0 :(得分:1)

使用函数http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_createoutputprogresspage创建 TOutputProgressWizardPage

function CreateOutputProgressPage(const ACaption, ADescription: String): TOutputProgressWizardPage;



[Code]
var
  ProgressPage: TOutputProgressWizardPage;

procedure InitializeWizard;
begin
  ProgressPage := CreateOutputProgressPage('Finalization of installation','');
end;

procedure CurPageChanged(CurPageID: Integer);
var
  I: Integer;
begin
  // Page is shown after installation when Finish page is shown
  if CurPageID = wpFinish then begin
    ProgressPage.SetText('Installing some 3rd party stuff...', '');
    ProgressPage.SetProgress(0, 0);
    ProgressPage.Show;
    try
      // Use exec/shellExec here to execute 3rd party app

      // Also you can adjust progress barr position here:
      for I := 0 to 10 do begin
        ProgressPage.SetProgress(I, 10);
        Sleep(100);
      end;
    finally
      ProgressPage.Hide;
    end;
  end else
    Result := True;
end;




答案 1 :(得分:0)

我终于找到了解决问题的方法。根据Slappy的回答,我使用了一个std MsgPage并根据我的需要调整它。请参阅TLama,以获得有关调整大小代码的不同主题的答案!

[Code]
var 
  RedistPage:   TOutputMsgWizardPage;

  DefaultTop, 
  DefaultLeft, 
  DefaultHeight,
  DefaultBackTop, 
  DefaultNextTop, 
  DefaultCancelTop,
  DefaultBevelTop, 
  DefaultBeveledLabelTop,
  DefaultInnerHeight,
  DefaultOuterHeight: Integer;

procedure InitializeWizard();
var 
  ReadMe: AnsiString;

begin

DefaultTop                  := WizardForm.Top;
DefaultLeft                 := WizardForm.Left;
DefaultHeight               := WizardForm.Height;
DefaultBackTop              := WizardForm.BackButton.Top;
DefaultNextTop              := WizardForm.NextButton.Top;
DefaultCancelTop            := WizardForm.CancelButton.Top;
DefaultBevelTop             := WizardForm.Bevel.Top;
DefaultBeveledLabelTop      := WizardForm.BeveledLabel.Top;
DefaultOuterHeight          := WizardForm.OuterNotebook.Height;
DefaultInnerHeight          := WizardForm.InnerNotebook.Height;

// save the contents of Readme.txt (non Unicode) in a string and build custom page
try
    ExtractTemporaryFiles('{tmp}\readme.txt');
    if LoadStringFromFile(ExpandConstant('{tmp}\readme.txt'), ReadMe) then
        RedistPage := CreateOutputMsgPage(wpReady,
            'Information', 'Please read the following important information about the installation before continuing.',ReadMe);
except
    ShowExceptionMessage;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;   // initialize result to not skip any page (not necessary, but safer)
  if PageID = RedistPage.ID then // if the page that is asked to be skipped is your custom page, then...
    Result := not IsTaskSelected('dexela_API');  // if the task is not selected, skip the page
end;

procedure ChangePageSize(HeightOffset: Integer);
begin
    WizardForm.Top := DefaultTop - (HeightOffset - DefaultHeight) div 2;
    WizardForm.Height := WizardForm.Height + (HeightOffset - DefaultHeight);
    WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (HeightOffset - DefaultHeight);
    WizardForm.InnerNotebook.Height :=  WizardForm.InnerNotebook.Height + (HeightOffset - DefaultHeight);
    WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (HeightOffset - DefaultHeight);
    WizardForm.CancelButton.Top := DefaultCancelTop + (HeightOffset - DefaultHeight);
    WizardForm.NextButton.Top := DefaultNextTop + (HeightOffset - DefaultHeight);
    WizardForm.BackButton.Top := DefaultBackTop + (HeightOffset - DefaultHeight);
    WizardForm.Bevel.Top := DefaultBevelTop + (HeightOffset - DefaultHeight);
end;

procedure CurPageChanged(CurPageID: Integer);
var 
    ComponentsPageTextHeight: Integer;
begin
    if (CurPageID = RedistPage.ID) and (IsTaskSelected('dexela_API'))then begin
        ChangePageSize(650);
        //Sleep(2000); // time for the user to recognize the text, before it is hidden by installer
        // Extract all Dexela files and launch them.
        try
            ExtractTemporaryFiles('{tmp}\Setup.msi');
        except
            ShowExceptionMessage;
        end;
        ShellExec('',ExpandConstant('{tmp}\Setup.msi'), '', '',SW_SHOW, ewWaitUntilTerminated, ResultCode);
    end;
end;