добавить кнопку только на одной странице в установочном файле - PullRequest
0 голосов
/ 19 августа 2011

Я хочу добавить кнопку в мой установочный файл, но на одной странице (страницу, которую я выбираю), но код, который я использовал, добавляет кнопку или 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 Ответ

1 голос
/ 19 августа 2011

Этот код работает для меня.

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