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

发布于 2024-11-30 20:01:59 字数 2266 浏览 1 评论 0原文

我想在我的安装文件中添加一个按钮,但在一页中(我选择的页面) 但我使用的代码在所有页面中添加按钮或 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;

i want to add a button to my instal file but in one page (the page i choose)
but the code i used add the button or URL in all pages

how i can modify the following code to add the button or the URL to only in one page

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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈情不如逗狗 2024-12-07 20:01:59

这段代码对我有用。

[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;

This code works for me.

[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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文