2012년 4월 13일 금요일

컴포넌트 선택에 따라 특정페이지 나타나게

 

Help 컴포넌트 선택시 Password 입력창이 나타나도록.

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output

[Files]

[Components]
Name: "help"; Description: "help"
Name: "test"; Description: "test"

[Code]
//Since you need the password later in the installation, and not always, you can not use the standard setup password page.
// You will instead create your own page and insert it after the components selection page:
var
  PasswordPage: TInputQueryWizardPage;

procedure InitializeWizard();
begin
  PasswordPage := CreateInputQueryPage(wpSelectComponents,
    'Your caption goes here',
    'Your description goes here',
    'Your subcaption goes here');
  PasswordPage.Add(SetupMessage(msgPasswordEditLabel), True);
end;

//Note that this uses the translated password caption, you may need to make the other three strings translatable as well.
//Next you will need to hide that page if the user has not selected the component for installation:
function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;
  if PageID = PasswordPage.ID then begin
    // show password page only if help file is selected for installation
    Result := not IsComponentSelected('help');
  end;
end;

//Finally you need to check the password, and prevent the user from going to the next page if the password is wrong:
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = PasswordPage.ID then begin
    // stay on this page if password is wrong
    if PasswordPage.Edits[0].Text <> '1234' then begin
      MsgBox(SetupMessage(msgIncorrectPassword), mbError, MB_OK);
      Result := False;
    end;
  end;
end;

댓글 없음:

댓글 쓰기