⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizard.pas

📁 源代码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  { Initialize images }
  WizardBitmapImage.BackColor := SetupHeader.WizardImageBackColor;
  WizardBitmapImage.Bitmap := WizardImage;
  WizardBitmapImage.Center := True;
  WizardBitmapImage.Stretch := (shWizardImageStretch in SetupHeader.Options);
  WizardBitmapImage2.BackColor := SetupHeader.WizardImageBackColor;
  WizardBitmapImage2.Bitmap := WizardImage;
  WizardBitmapImage2.Center := True;
  WizardBitmapImage2.Stretch := (shWizardImageStretch in SetupHeader.Options);
  WizardSmallBitmapImage.Bitmap := WizardSmallImage;
  WizardSmallBitmapImage.Stretch := (shWizardImageStretch in SetupHeader.Options);
  PreparingErrorBitmapImage.Bitmap.Handle := LoadBitmap(HInstance, 'STOPIMAGE');
  PreparingErrorBitmapImage.ReplaceColor := clSilver;
  PreparingErrorBitmapImage.ReplaceWithColor := Color;
  LoadSelectDirAndGroupImages;

  { Initialize wpWelcome page }
  RegisterExistingPage(wpWelcome, WelcomePage, nil, '', '');
  WelcomeLabel1.Caption := ExpandSetupMessage(msgWelcomeLabel1) + SNewLine;
  AdjustLabelHeight(WelcomeLabel1);
  IncTopDecHeight(WelcomeLabel2, (WelcomeLabel1.Top + WelcomeLabel1.Height) -
    WelcomeLabel2.Top);
  WelcomeLabel2.Caption := ExpandSetupMessage(msgWelcomeLabel2) + SNewLine2 +
    SetupMessages[msgClickNext];

  { Initialize wpLicense page }
  RegisterExistingPage(wpLicense, InnerPage, LicensePage,
    SetupMessages[msgWizardLicense], SetupMessages[msgLicenseLabel]);
  LicenseLabel1.Caption := ExpandSetupMessage(msgLicenseLabel3);
  I := AdjustLabelHeight(LicenseLabel1);
  IncTopDecHeight(LicenseMemo, I);
  LicenseAcceptedRadio.Caption := SetupMessages[msgLicenseAccepted];
  LicenseNotAcceptedRadio.Caption := SetupMessages[msgLicenseNotAccepted];

  { Initialize wpPassword page }
  RegisterExistingPage(wpPassword, InnerPage, PasswordPage,
    SetupMessages[msgWizardPassword], SetupMessages[msgPasswordLabel1]);
  PasswordLabel.Caption := SetupMessages[msgPasswordLabel3];
  PasswordEditLabel.Caption := SetupMessages[msgPasswordEditLabel];
  I := AdjustLabelHeight(PasswordLabel);
  PasswordEditLabel.Top := PasswordEditLabel.Top + I;
  Inc(I, AdjustLabelHeight(PasswordEditLabel));
  PasswordEdit.Top := PasswordEdit.Top + I;

  { Initialize wpInfoBefore page }
  RegisterExistingPage(wpInfoBefore, InnerPage, InfoBeforePage,
    SetupMessages[msgWizardInfoBefore], SetupMessages[msgInfoBeforeLabel]);
  InfoBeforeClickLabel.Caption := SetupMessages[msgInfoBeforeClickLabel];
  I := AdjustLabelHeight(InfoBeforeClickLabel);
  IncTopDecHeight(InfoBeforeMemo, I);

  { Initialize wpUserInfo page }
  RegisterExistingPage(wpUserInfo, InnerPage, UserInfoPage,
    SetupMessages[msgWizardUserInfo], SetupMessages[msgUserInfoDesc]);
  UserInfoNameLabel.Caption := SetupMessages[msgUserInfoName];
  I := AdjustLabelHeight(UserInfoNameLabel);
  UserInfoNameEdit.Top := UserInfoNameEdit.Top + I;

  UserInfoOrgLabel.Top := UserInfoOrgLabel.Top + I;
  UserInfoOrgLabel.Caption := SetupMessages[msgUserInfoOrg];
  Inc(I, AdjustLabelHeight(UserInfoOrgLabel));
  UserInfoOrgEdit.Top := UserInfoOrgEdit.Top + I;

  if NeedSerial then begin
    UserInfoSerialLabel.Top := UserInfoSerialLabel.Top + I;
    UserInfoSerialLabel.Caption := SetupMessages[msgUserInfoSerial];
    Inc(I, AdjustLabelHeight(UserInfoSerialLabel));
    UserInfoSerialEdit.Top := UserInfoSerialEdit.Top + I;
  end else begin
    UserInfoSerialLabel.Visible := False;
    UserInfoSerialEdit.Visible := False;
  end;

  { Initialize wpSelectDir page }
  RegisterExistingPage(wpSelectDir, InnerPage, SelectDirPage,
    SetupMessages[msgWizardSelectDir], ExpandSetupMessage(msgSelectDirDesc));
  SelectDirLabel.Caption := ExpandSetupMessage(msgSelectDirLabel3);
  X := SelectDirBitmapImage.Left + SelectDirBitmapImage.Width + ScalePixelsX(12);
  SelectDirLabel.SetBounds(X, SelectDirLabel.Top,
    SelectDirLabel.Width - (X - SelectDirLabel.Left), SelectDirLabel.Height);
  AdjustLabelHeight(SelectDirLabel);
  if SelectDirLabel.Height < SelectDirBitmapImage.Height then
    SelectDirLabel.Top := SelectDirLabel.Top +
      (SelectDirBitmapImage.Height - (SelectDirLabel.Height - 1)) div 2;
  SelectDirBrowseLabel.Caption := ExpandSetupMessage(msgSelectDirBrowseLabel);
  I := IntMax(
    SelectDirBitmapImage.Top + SelectDirBitmapImage.Height + ScalePixelsY(12),
    SelectDirLabel.Top + SelectDirLabel.Height - 1 + ScalePixelsY(13)) -
    SelectDirBrowseLabel.Top;
  SelectDirBrowseLabel.Top := SelectDirBrowseLabel.Top + I;
  Inc(I, AdjustLabelHeight(SelectDirBrowseLabel));
  DirEdit.Top := DirEdit.Top + I;
  DirBrowseButton.Caption := SetupMessages[msgButtonWizardBrowse];
  X := CalculateButtonWidth([msgButtonWizardBrowse]);
  DirBrowseButton.SetBounds(DirBrowseButton.Left + DirBrowseButton.Width - X,
    DirBrowseButton.Top + I, X, DirBrowseButton.Height);
  DirEdit.Width := DirBrowseButton.Left - ScalePixelsX(10) - DirEdit.Left;
  DiskSpaceLabel.Caption := ExpandSetupMessage(msgDiskSpaceMBLabel);
  DiskSpaceLabel.Top := DiskSpaceLabel.Top - AdjustLabelHeight(DiskSpaceLabel);

  { Initialize wpSelectComponents page }
  RegisterExistingPage(wpSelectComponents, InnerPage, SelectComponentsPage,
    SetupMessages[msgWizardSelectComponents], ExpandSetupMessage(msgSelectComponentsDesc));
  SelectComponentsLabel.Caption := ExpandSetupMessage(msgSelectComponentsLabel2);
  I := AdjustLabelHeight(SelectComponentsLabel);
  TypesCombo.Top := TypesCombo.Top + I;
  IncTopDecHeight(ComponentsList, I);
  ComponentsDiskSpaceLabel.Caption := ExpandSetupMessage(msgComponentsDiskSpaceMBLabel);
  AdjustLabelHeight(ComponentsDiskSpaceLabel);

  if HasCustomType and (Entries[seType].Count = 1) then begin
    TypesCombo.Visible := False;
    IncTopDecHeight(ComponentsList, TypesCombo.Top - ComponentsList.Top);
  end;

  { Initialize wpSelectProgramGroup page }
  RegisterExistingPage(wpSelectProgramGroup, InnerPage, SelectProgramGroupPage,
    SetupMessages[msgWizardSelectProgramGroup], ExpandSetupMessage(msgSelectStartMenuFolderDesc));
  SelectStartMenuFolderLabel.Caption := ExpandSetupMessage(msgSelectStartMenuFolderLabel3);
  X := SelectGroupBitmapImage.Left + SelectGroupBitmapImage.Width + ScalePixelsX(12);
  SelectStartMenuFolderLabel.SetBounds(X, SelectStartMenuFolderLabel.Top,
    SelectStartMenuFolderLabel.Width - (X - SelectStartMenuFolderLabel.Left),
    SelectStartMenuFolderLabel.Height);
  AdjustLabelHeight(SelectStartMenuFolderLabel);
  if SelectStartMenuFolderLabel.Height < SelectGroupBitmapImage.Height then
    SelectStartMenuFolderLabel.Top := SelectStartMenuFolderLabel.Top +
      (SelectGroupBitmapImage.Height - (SelectStartMenuFolderLabel.Height - 1)) div 2;
  SelectStartMenuFolderBrowseLabel.Caption := ExpandSetupMessage(msgSelectStartMenuFolderBrowseLabel);
  I := IntMax(
    SelectGroupBitmapImage.Top + SelectGroupBitmapImage.Height + ScalePixelsY(12),
    SelectStartMenuFolderLabel.Top + SelectStartMenuFolderLabel.Height - 1 + ScalePixelsY(13)) -
    SelectStartMenuFolderBrowseLabel.Top;
  SelectStartMenuFolderBrowseLabel.Top := SelectStartMenuFolderBrowseLabel.Top + I;
  Inc(I, AdjustLabelHeight(SelectStartMenuFolderBrowseLabel));
  GroupEdit.Top := GroupEdit.Top + I;
  GroupBrowseButton.Caption := SetupMessages[msgButtonWizardBrowse];
  X := CalculateButtonWidth([msgButtonWizardBrowse]);
  GroupBrowseButton.SetBounds(GroupBrowseButton.Left + GroupBrowseButton.Width - X,
    GroupBrowseButton.Top + I, X, GroupBrowseButton.Height);
  GroupEdit.Width := GroupBrowseButton.Left - ScalePixelsX(10) - GroupEdit.Left;
  if HasTaskIcons then
    NoIconsCheck.Caption := SetupMessages[msgNoProgramGroupCheck2]
  else
    NoIconsCheck.Caption := SetupMessages[msgNoIconsCheck];

  { Initialize wpSelectTasks page }
  RegisterExistingPage(wpSelectTasks, InnerPage, SelectTasksPage,
    SetupMessages[msgWizardSelectTasks], ExpandSetupMessage(msgSelectTasksDesc));
  SelectTasksLabel.Caption := ExpandSetupMessage(msgSelectTasksLabel2);
  I := AdjustLabelHeight(SelectTasksLabel);
  IncTopDecHeight(TasksList, I);
  TasksList.BorderStyle := bsNone;
  TasksList.MinItemHeight := ScalePixelsY(22);
  TasksList.ShowLines := shShowTasksTreeLines in SetupHeader.Options;

  { Initialize wpReady page }
  RegisterExistingPage(wpReady, InnerPage, ReadyPage,
    SetupMessages[msgWizardReady], ExpandSetupMessage(msgReadyLabel1));

  { Initialize wpPreparing page }
  RegisterExistingPage(wpPreparing, InnerPage, PreparingPage,
    SetupMessages[msgWizardPreparing], ExpandSetupMessage(msgPreparingDesc));

  { Initialize wpInstalling page }
  RegisterExistingPage(wpInstalling, InnerPage, InstallingPage,
    SetupMessages[msgWizardInstalling], ExpandSetupMessage(msgInstallingLabel));

  { Initialize wpInfoAfter page }
  RegisterExistingPage(wpInfoAfter, InnerPage, InfoAfterPage,
    SetupMessages[msgWizardInfoAfter], SetupMessages[msgInfoAfterLabel]);
  InfoAfterClickLabel.Caption := SetupMessages[msgInfoAfterClickLabel];
  I := AdjustLabelHeight(InfoAfterClickLabel);
  IncTopDecHeight(InfoAfterMemo, I);

  { Initialize wpFinished page }
  RegisterExistingPage(wpFinished, FinishedPage, nil, '', '');
  SetFontNameSize(FinishedHeadingLabel.Font, LangOptions.WelcomeFontName,
    LangOptions.WelcomeFontSize, '', 12);
  FinishedHeadingLabel.Font.Style := [fsBold];
  FinishedHeadingLabel.Caption := ExpandSetupMessage(msgFinishedHeadingLabel) +
    SNewLine;
  AdjustLabelHeight(FinishedHeadingLabel);
  FinishedLabel.Top := FinishedHeadingLabel.Top + FinishedHeadingLabel.Height;
  YesRadio.Caption := SetupMessages[msgYesRadio];
  NoRadio.Caption := SetupMessages[msgNoRadio];
  RunList.MinItemHeight := ScalePixelsY(22);

  { Initialize BeveledLabel }
  BeveledLabel.Caption := ' ' + SetupMessages[msgBeveledLabel] + ' ';

  { Don't set UseRichEdit to True on the TRichEditViewers unless they are going
    to be used. There's no need to load riched*.dll unnecessarily. }
  if ActiveLicenseText <> '' then begin
    LicenseMemo.UseRichEdit := True;
    LicenseMemo.RTFText := ActiveLicenseText;
  end;
  if ActiveInfoBeforeText <> '' then begin
    InfoBeforeMemo.UseRichEdit := True;
    InfoBeforeMemo.RTFText := ActiveInfoBeforeText;
  end;
  if ActiveInfoAfterText <> '' then begin
    InfoAfterMemo.UseRichEdit := True;
    InfoAfterMemo.RTFText := ActiveInfoAfterText;
  end;

  { Append an 'About Setup' item to the wizard form also }
  SystemMenu := GetSystemMenu(Handle, False);
  AppendMenu(SystemMenu, MF_SEPARATOR, 0, nil);
  AppendMenu(SystemMenu, MF_STRING, 9999, PChar(SetupMessages[msgAboutSetupMenuItem]));

  { Read settings from a previous install if available }
  FindPreviousData;
  PrevSetupTypeIndex := -1; //assigned later

  { Assign default user name & organization on User Info page }
  if shUserInfoPage in SetupHeader.Options then begin
    if PrevUserInfoName = '' then begin
      UserInfoNameEdit.Text := ExpandConst(SetupHeader.DefaultUserInfoName);
      UserInfoOrgEdit.Text := ExpandConst(SetupHeader.DefaultUserInfoOrg);
      UserInfoSerialEdit.Text := ExpandConst(SetupHeader.DefaultUserInfoSerial);
    end
    else begin
      UserInfoNameEdit.Text := PrevUserInfoName;
      UserInfoOrgEdit.Text := PrevUserInfoOrg;
      UserInfoSerialEdit.Text := PrevUserInfoSerial;
    end;
  end;

  { Assign default directory name }
  if shCreateAppDir in SetupHeader.Options then begin
    ExpandedDefaultDirName := ExpandConst(SetupHeader.DefaultDirName);
    if InitDir <> '' then
      P := InitDir
    else begin
      P := PrevAppDir;
      if P = '' then
        P := ExpandedDefaultDirName;
    end;
    P := RemoveBackslashUnlessRoot(PathExpand(P));
    DirEdit.Text := P;
  end
  else
    DirEdit.Text := WinDir;

  { Fill types list and assign default type }
  if Entries[seType].Count > 0 then begin
    //first fill list
    TypesCombo.Clear();
    for I := 0 to Entries[seType].Count-1 do begin
      TypeEntry := PSetupTypeEntry(Entries[seType][I]);
      TypesCombo.Items.AddObject(ExpandConst(TypeEntry.Description), TObject(TypeEntry));
      if Comparetext(TypeEntry.Name, PrevSetupType) = 0 then
        PrevSetupTypeIndex := I;
    end;
    //now assign default type
    if PrevSetupTypeIndex <> -1 then
      TypesCombo.ItemIndex := PrevSetupTypeIndex
    else
      TypesCombo.ItemIndex := 0;
  end;

  { Fill components list and assign default components}
  //find the biggest component
  MaxComponentSize.Hi := 0;
  MaxComponentSize.Lo := 0;
  for I := 0 to Entries[seComponent].Count-1 do begin
    ComponentEntry := PSetupComponentEntry(Entries[seComponent][I]);
    if Compare64(ComponentEntry.Size, MaxComponentSize) > 0 then
      MaxComponentSize := ComponentEntry.Size;
  end;

  //first fill list
  ComponentsList.Clear();
  ComponentsList.Flat := shFlatComponentsList in SetupHeader.Options;
  for I := 0 to Entries[seComponent].Count-1 do begin
    ComponentEntry := PSetupComponentEntry(Entries[seComponent][I]);
    if coExclusive in ComponentEntry.Options then
      ComponentsList.AddRadioButton(ExpandConst(ComponentEntry.Description), '', ComponentEntry.Level,
        False, not (coFixed in ComponentEntry.Options), TObject(ComponentEntry))
    else
      ComponentsList.AddCheckBox(ExpandConst(ComponentEntry.Description), '', ComponentEntry.Level,
        False, not (coFixed in ComponentEntry.Options), ComponentEntry.Used,
        not (coDontInheritCheck in ComponentEntry.Options), TObject(ComponentEntry));
  end;

  //now assign default components
  if InitComponents.Count <> 0 then begin
    SetSelectedComponents(InitComponents, nil);
    //try to find a custom type. if there's no custom type the UsePreviousSetupType won't
    //work and if the install is not silent the type list won't display a custom type.
    if HasCustomType then begin
      for I := 0 to Entries[seType].Count-1 do begin
        TypeEntry := PSetupTypeEntry(Entries[seType][I]);
        if toIsCustom in TypeEntry.Options then begin
          TypesCombo.ItemIndex := I;
          Break;
        end;
      end;
    end;
  end else begin
    if PrevSetupTypeIndex <> -1 then begin
      TypeEntry := PSetupTypeEntry(Entries[seType][PrevSetupTypeIndex]);
      if toIsCustom in TypeEntry.Options then begin
        //the previous setup type is a custom type: first select the default components
        //for the default type (usually the full type). needed for new components.
        TypeEntry := PSetupTypeEntry(Entries[seType][0]);
        SetSelectedComponentsFromType(TypeEntry.Name, False);
        //now restore the customization
        SetSelectedComponents(PrevSelectedComponents, PrevDeselectedComponents);
      end else begin
        //this is not a custom type, so just select components based on the previous type
        TypeEntry := PSetupTypeEntry(Entries[seType][PrevSetupTypeIndex]);
        SetSelectedComponentsFromType(TypeEntry.Name, False);
      end;
    end else if Entries[seType].Count > 0 then begin
      TypeEntry := PSetupTypeEntry(Entries[seType][0]);
      SetSelectedComponentsFromType(TypeEntry.Name, False);
    end;
  end;

  UpdateComponentSizes();
  CalcCurrentComponentsSpace();

  //Show or hide the components list based on the selected type
  if HasCustomType then begin
    TypeEntry := PSetupTypeEntry(Entries[seType][TypesCombo.ItemIndex]);
    if (toIsCustom in TypeEntry.Options) or (shAlwaysShowComponentsList in SetupHeader.Options) then
      ComponentsList.Visible := True
    else
      ComponentsList.Visible := False;
  end else
    ComponentsList.Visible := False;
  ComponentsDiskSpaceLabel.Visible := ComponentsList.Visible;

  //Store the initial setup type and components (only necessary if customizable)
  if HasCustomType then begin
    InitialSetupTypeIndex := TypesCombo.ItemIndex;
    GetSelectedComponents(InitialSelectedComponents, False, False);
  end;

  { Assign default group name }
  ExpandedDefaultGroupName := ExpandConst(SetupHeader.DefaultGroupName);
  if (InitProgramGroup <> '') and not(shDisableProgramGroupPage in SetupHeader.Options) then
    { ^ InitProgramGroup currently isn't supported for installations with
      shDisableProgramGroupPage set. If the wizard page isn't displayed, it
      doesn't get a chance to validate the program group name specified. }
    P := InitProgramGroup
  else begin
    if (PrevGroup = '') or (PrevGroup = '(Default)') then
      P := ExpandedDefaultGroupName
    else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -