仅在安装文件中的一个页面中添加按钮

时间:2011-08-18 21:12:04

标签: installation setup-project inno-setup

我想在我的安装文件中添加一个按钮,但是在一个页面中(我选择的页面) 但我使用的代码在所有页面中添加了按钮或URL

我如何修改以下代码,只将按钮或URL添加到一个页面

function InitializeSetup: Boolean;
var
  S: AnsiString;
begin
  // Show the contents of Readme.txt (non Unicode) in a message box
  ExtractTemporaryFile('Info.rtf');
  Result := True;
end;

procedure AboutButtonOnClick(Sender: TObject);

var
 Document : String;
 WordPad : String;
 ErrorCode : Integer;
begin
   // Typical Location on XP and later.
   WordPad := ExpandConstant('{pf}') + '\Windows NT\Accessories\WordPad.exe'
   // Find word pad
   if Not FileExists(WordPad) then
   begin
     // Location in Windows 95/98
     WordPad := ExpandConstant('{pf}') + '\Accessories\WordPad.exe'
     if Not FileExists(WordPad) then
     begin
       // Fall back to anything associated with document.
       WordPad := Document;
       Document := '';
     end;
   end;

   if not ShellExec('open',WordPad,ExpandConstant('{tmp}\Info.rtf'),'',SW_SHOW,ewNoWait,ErrorCode) then
   begin
      MsgBox(SysErrorMessage(ErrorCode),mbError,MB_OK);
   end;
end;

procedure URLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://WwW.GooGle.CoM', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure InitializeWizard();
var
  AboutButton, CancelButton: TButton;
  URLLabel: TNewStaticText;
begin
  { Custom wizard pages }

  { Other custom controls }

  CancelButton := WizardForm.CancelButton;

  AboutButton := TButton.Create(WizardForm);
  AboutButton.Cursor := crHand;
  AboutButton.Left := 20;
  AboutButton.Top := 326;
  AboutButton.Width := CancelButton.Width;
  AboutButton.Height := CancelButton.Height;
  AboutButton.Caption := '&Info...';
  AboutButton.OnClick := @AboutButtonOnClick;
  AboutButton.Parent := WizardForm;

  URLLabel := TNewStaticText.Create(WizardForm);
  URLLabel.Caption := 'WwW.GooGle.CoM';
  URLLabel.Cursor := crHand;
  URLLabel.OnClick := @URLLabelOnClick;
  URLLabel.Parent := WizardForm;
  { Alter Font *after* setting Parent so the correct defaults are inherited first }
  URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  URLLabel.Font.Color := clBlue;
  { تنفع تتعمل بارقات لتحديد مكان الزر او لينك مثلا }
  URLLabel.Top := 330;
  URLLabel.Left := 100;
end;

1 个答案:

答案 0 :(得分:1)

此代码适用于我。

[code]
function InitializeSetup: Boolean;
var
  S: AnsiString;
begin
  // Show the contents of Readme.txt (non Unicode) in a message box
  ExtractTemporaryFile('Info.rtf');
  Result := True;
end;

procedure AboutButtonOnClick(Sender: TObject);

var
 Document : String;
 WordPad : String;
 ErrorCode : Integer;
begin
   // Typical Location on XP and later.
   WordPad := ExpandConstant('{pf}') + '\Windows NT\Accessories\WordPad.exe'
   // Find word pad
   if Not FileExists(WordPad) then
   begin
     // Location in Windows 95/98
     WordPad := ExpandConstant('{pf}') + '\Accessories\WordPad.exe'
     if Not FileExists(WordPad) then
     begin
       // Fall back to anything associated with document.
       WordPad := Document;
       Document := '';
     end;
   end;

   if not ShellExec('open',WordPad,ExpandConstant('{tmp}\Info.rtf'),'',SW_SHOW,ewNoWait,ErrorCode) then
   begin
      MsgBox(SysErrorMessage(ErrorCode),mbError,MB_OK);
   end;
end;

procedure URLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://WwW.GooGle.CoM', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;


var 
  AboutButton, CancelButton: TButton;
  URLLabel: TNewStaticText;


procedure CurPageChanged(CurPage: Integer);

begin
//Change the value below to change which page the button and label appear on.  
  if CurPage = wpWelcome then
  begin
  CancelButton := WizardForm.CancelButton;
  AboutButton := TButton.Create(WizardForm);
  AboutButton.Cursor := crHand;
  AboutButton.Left := 20;
  AboutButton.Top := 326;
  AboutButton.Width := CancelButton.Width;
  AboutButton.Height := CancelButton.Height;
  AboutButton.Caption := '&Info...';
  AboutButton.OnClick := @AboutButtonOnClick;
  AboutButton.Parent := WizardForm;

  URLLabel := TNewStaticText.Create(WizardForm);
  URLLabel.Caption := 'WwW.GooGle.CoM';
  URLLabel.Cursor := crHand;
  URLLabel.OnClick := @URLLabelOnClick;
  URLLabel.Parent := WizardForm;
  { Alter Font *after* setting Parent so the correct defaults are inherited first }
  URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  URLLabel.Font.Color := clBlue;
  URLLabel.Top := 330;
  URLLabel.Left := 100;
  end
  //Change the value below to match the value above so the button is hidden on pages other than the one you want.
  if CurPage <> wpWelcome then
  begin
  AboutButton.Visible := False;
  URLLabel.Visible := False;
  end
end;
相关问题