Вопрос Перейти на определенную страницу

Хамик

Старожил
Как в функцию function BackButtonClick(CurPageID: Integer): Boolean; прописать переход на кастомную страницу? Или как-то по другому можно? Если так указать не работает.
Код:
function BackButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = Page[2].ID then Page[1].Surface.Show else
result := true;
end;
Наверное самой функции маловато будет, вот еще пример
Код:
[setup]
appname=app
appvername=app
CreateAppDir=no

[code]
var
Page: array [1..2] of TWizardPage;
Param, Params: TNewButton;

procedure OnClick(Sender: TObject);
begin
Page[2].Surface.Show;
end;

procedure aem();
begin
Page[1] := CreateCustomPage(wpWelcome, 'первая кастомная страница', '');
///////////////////////////////////////////////////////////////////////////////////////////////////////
Param := TNewButton.Create(Page[1]);
Param.Parent := Page[1].Surface;
Param.Caption := 'первая кастомная страница';
Param.OnClick := @OnClick;
Param.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));
///////////////////////////////////////////////////////////////////////////////////////////////////////
Page[2] := CreateCustomPage(Page[1].ID, 'вторая кастомная страница', '');
Params := TNewButton.Create(Page[2]);
Params.Parent := Page[2].Surface;
Params.Caption := 'вторая кастомная страница';
Params.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));
///////////////////////////////////////////////////////////////////////////////////////////////////////
end;

procedure InitializeWizard();
begin
  aem();
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
   if PageID = Page[2].ID then result := true;
end;

function BackButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = Page[2].ID then Page[1].Surface.Show else
result := true;
end;
 

nik1967

Old Men
Проверенный
Хм,
Код:
[setup]
appname=app
appvername=app
CreateAppDir=no

[code]
var
    Page: array [1..2] of TWizardPage;
    Param, Params: TNewButton;

procedure OnClick(Sender: TObject);
begin
    case Sender of
        Param: Page[2].Surface.Show;
        Params: Page[1].Surface.Show;
    end;
end;

procedure aem();
begin
    Page[1]:= CreateCustomPage(wpWelcome, 'первая кастомная страница', '');
///////////////////////////////////////////////////////////////////////////////////////////////////////
    Param:= TNewButton.Create(Page[1]);
    Param.Parent:= Page[1].Surface;
    Param.Caption:= 'первая кастомная страница';
    Param.OnClick:= @OnClick;
    Param.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));
///////////////////////////////////////////////////////////////////////////////////////////////////////
    Page[2]:= CreateCustomPage(Page[1].ID, 'вторая кастомная страница', '');
    Params:= TNewButton.Create(Page[2]);
    Params.Parent:= Page[2].Surface;
    Params.Caption:= 'вторая кастомная страница';
    Params.OnClick:= @OnClick;
    Params.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));
///////////////////////////////////////////////////////////////////////////////////////////////////////
end;

procedure InitializeWizard();
begin
  aem();
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  if PageID = Page[2].ID then result:= true;
end;
 

Хамик

Старожил
nik1967, нет, вторая кнопка только для надписи чтобы увидить вторую кастомную страницу, она только для примера. И как правильно указать при нажатии на кнопку переход на страницу page2, чтобы и лейблы были с page2?

Код:
[setup]
appname=app
appvername=app
CreateAppDir=no

[code]
var
Page: array [1..2] of TWizardPage;
Param: TNewButton;

procedure OnClick(Sender: TObject);
begin
Page[2].Surface.Show;
end;

procedure aem();
begin
Page[1] := CreateCustomPage(wpWelcome, 'первая кастомная страница', '');
///////////////////////////////////////////////////////////////////////////////////////////////////////
Param := TNewButton.Create(Page[1]);
Param.Parent := Page[1].Surface;
Param.Caption := 'первая кастомная страница';
Param.OnClick := @OnClick;
Param.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));

Page[2] := CreateCustomPage(Page[1].ID, 'вторая кастомная страница', '');
end;

procedure InitializeWizard();
begin
  aem();
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
   if PageID = Page[2].ID then result := true;
end;

function BackButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = Page[2].ID then Page[1].Surface.Show else
result := true;
end;
 
Последнее редактирование:

Хамик

Старожил
Все решил данную задачу
Код:
[setup]
appname=app
appvername=app
CreateAppDir=no

[code]
var
Page: array [1..2] of TWizardPage;
Param: TNewButton;
page2: boolean;

procedure OnClick(Sender: TObject);
begin
page2 := true;
WizardForm.NextButton.OnClick(WizardForm.NextButton);
end;

procedure aem();
begin
Page[1] := CreateCustomPage(wpWelcome, 'первая кастомная страница', '');
///////////////////////////////////////////////////////////////////////////////////////////////////////
Param := TNewButton.Create(Page[1]);
Param.Parent := Page[1].Surface;
Param.Caption := 'первая кастомная страница';
Param.OnClick := @OnClick;
Param.SetBounds(ScaleX(160), ScaleY(100), ScaleX(160), ScaleY(30));

Page[2] := CreateCustomPage(Page[1].ID, 'вторая кастомная страница', '');
end;

procedure InitializeWizard();
begin
  aem();
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = Page[2].ID then page2 := false;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
if page2 <> true then
   if PageID = Page[2].ID then result := true;
end;
 

ZVSRus

Участник
Хамик. А так как вариант не пойдёт?
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
OutputDir=.
UsePreviousAppDir=no
UsePreviousGroup=no

[Code]
var
  Flag            : Boolean;
  ComponentPage   : TWizardPage;
  NewCheckBox1    : TNewCheckBox;
  NewCheckBox2    : TNewCheckBox;
  NewCheckBox3    : TNewCheckBox;
  NewCheckBox4    : TNewCheckBox;

  NewRadioButton1 : TNewRadioButton;
  NewRadioButton2 : TNewRadioButton;
  NewRadioButton3 : TNewRadioButton;
  NewRadioButton4 : TNewRadioButton;
  NewButton1      : TNewButton;

  SettingPanel    : TPanel;

////////////////////////////////////////////////////////
procedure SettingHideShowOnClick(Sender: TObject);    //
begin                                                 //
if Flag = False then begin                           //
   SettingPanel.Hide;                                 //
   Flag:= True;                                       //
   NewButton1.Caption   := 'На страницу-2';           //
   WizardForm.PageNameLabel.Caption:= 'Страница №1';  //
end else begin                                       //
   SettingPanel.Show;                                 //
   Flag:= False;                                      //
  NewButton1.Caption    := 'На страницу-1';           //
  WizardForm.PageNameLabel.Caption:= 'Страница №2';   //
end;                                                 //
end;                                                  //
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
procedure CurPageChanged(CurPageID: Integer);         //
begin                                                 //
  NewButton1.Hide;                                    //
  SettingPanel.Hide;                                  //
  case CurPageID of                                   //
  ComponentPage.ID:                                   //
  begin                                               //
    NewButton1.Show;                                  //
//====================================================//
  if Flag = False then begin                          //
    Flag:= True;                                      //
    NewButton1.Caption   := 'На страницу-2';          //
  end else begin                                      //
    NewButton1.Show;                                  //
    Flag:= True;                                      //
    NewButton1.Caption   := 'На страницу-2';          //
  end;                                                //
  end;                                                //
end;                                                 //
end;                                                  //
////////////////////////////////////////////////////////

procedure InitializeWizard();
begin
  ComponentPage := CreateCustomPage(wpWelcome, 'Страница №1', '...');

  NewCheckBox1 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox1 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(20);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox1';
  end;

  NewCheckBox2 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox2 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(20);
    Top := ScaleY(100);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox2';
  end;

  NewCheckBox3 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox3 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(280);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox3';
  end;

  NewCheckBox4 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox4 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(280);
    Top := ScaleY(100);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox4';
  end;

  NewButton1 := TNewButton.Create(WizardForm);
  with NewButton1 do
  begin
    Parent := WizardForm;
    Left := ScaleX(157);
    Top := ScaleY(327);
    Width := ScaleX(80);
    Height := ScaleY(23);
    Caption := 'На страницу 2';
    OnClick     := @SettingHideShowOnClick;           
    Flag        := True;
  end;

  SettingPanel  := TPanel.Create(WizardForm);
  with SettingPanel do
  begin
    Parent      := ComponentPage.Surface;
    Left        := ScaleX(0);
    Top         := ScaleY(0);                       
    Width       := ScaleX(417);                       
    Height      := ScaleY(237);                       
    BevelOuter  := bvNone;
  end;                                                

  NewRadioButton1 := TNewRadioButton.Create(WizardForm);
  with NewRadioButton1 do
  begin
    Parent := SettingPanel;
    Left := ScaleX(20);
    Top := ScaleY(40);
    Width := ScaleX(113);
    Height := ScaleY(17);
    Caption := 'NewRadioButton1';
  end;

  NewRadioButton2 := TNewRadioButton.Create(WizardForm);
  with NewRadioButton2 do
  begin
    Parent := SettingPanel;
    Left := ScaleX(20);
    Top := ScaleY(100);
    Width := ScaleX(113);
    Height := ScaleY(17);
    Caption := 'NewRadioButton2';
  end;

  NewRadioButton3 := TNewRadioButton.Create(WizardForm);
  with NewRadioButton3 do
  begin
    Parent := SettingPanel;
    Left := ScaleX(280);
    Top := ScaleY(40);
    Width := ScaleX(113);
    Height := ScaleY(17);
    Caption := 'NewRadioButton3';
  end;

  NewRadioButton4 := TNewRadioButton.Create(WizardForm);
  with NewRadioButton4 do
  begin
    Parent := SettingPanel;
    Left := ScaleX(280);
    Top := ScaleY(100);
    Width := ScaleX(113);
    Height := ScaleY(17);
    Caption := 'NewRadioButton4';
  end;
end;
 

ZVSRus

Участник
Как вариант можно ещё так
Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
OutputDir=.

UsePreviousAppDir=no
UsePreviousGroup=no

[Code]
var
  ComponentPage : TWizardPage;

  SettingPanel1 : TPanel;
  NewCheckBox1  : TNewCheckBox;
  NewCheckBox2  : TNewCheckBox;
  SettingButton1: TNewButton;
  SettingButton2: TNewButton;

  SettingPanel2 : TPanel;
  NewCheckBox3  : TNewCheckBox;
  NewCheckBox4  : TNewCheckBox;
  SettingButton3: TNewButton;
  SettingButton4: TNewButton;

  SettingPanel3 : TPanel;
  NewCheckBox5  : TNewCheckBox;
  NewCheckBox6  : TNewCheckBox;
  SettingButton5: TNewButton;
  SettingButton6: TNewButton;

procedure SettingButtonClick(Sender: TObject);
begin                                           
case TNewButton(Sender) of                
  SettingButton1:                                     
begin                                          
  SettingPanel1.Hide;                              
  SettingPanel3.Hide;
  SettingPanel2.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 2';
end;
  SettingButton2:
begin
  SettingPanel1.Hide;
  SettingPanel2.Hide;
  SettingPanel3.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 3';
end;
  SettingButton3:
begin
  SettingPanel2.Hide;
  SettingPanel3.Hide;
  SettingPanel1.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 1';
end;
  SettingButton4:
begin
  SettingPanel1.Hide;
  SettingPanel2.Hide;
  SettingPanel3.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 3';
end;
  SettingButton5:
begin
  SettingPanel2.Hide;
  SettingPanel3.Hide;
  SettingPanel1.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 1';
end;
  SettingButton6:
begin
  SettingPanel1.Hide;
  SettingPanel3.Hide;
  SettingPanel2.Show;
  WizardForm.PageNameLabel.Caption:= 'Страница 2';
end;
end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin                                                              
    SettingPanel2.Hide;
    SettingPanel3.Hide;
    case CurPageID of
  ComponentPage.ID:
  begin
    SettingPanel1.Show;
    WizardForm.PageNameLabel.Caption:= 'Страница 1';                                             
  end;
end;
end;

procedure InitializeWizard();
begin
  ComponentPage := CreateCustomPage(wpWelcome, 'Страница 1', '...');

  SettingPanel1 := TPanel.Create(WizardForm);
  with SettingPanel1 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(417);
    Height := ScaleY(237);
    BevelOuter := bvNone;
    Caption := 'Страница 1';
  end;

  NewCheckBox1 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox1 do
  begin
    Parent := SettingPanel1;
    Left := ScaleX(30);
    Top := ScaleY(30);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '01';
  end;

  NewCheckBox2 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox2 do
  begin
    Parent := SettingPanel1;
    Left := ScaleX(30);
    Top := ScaleY(60);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '02';
  end;

  SettingButton1 := TNewButton.Create(WizardForm);
  with SettingButton1 do
  begin
    Parent := SettingPanel1;
    Left := ScaleX(5);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 2';
    OnClick     := @SettingButtonClick;
  end;

  SettingButton2 := TNewButton.Create(WizardForm);
  with SettingButton2 do
  begin
    Parent := SettingPanel1;
    Left := ScaleX(212);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 3';
    OnClick     := @SettingButtonClick;
  end;

//===============================================//

  SettingPanel2 := TPanel.Create(WizardForm);
  with SettingPanel2 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(417);
    Height := ScaleY(237);
    BevelOuter := bvNone;
    Caption := 'Страница 2';
  end;

  NewCheckBox3 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox3 do
  begin
    Parent := SettingPanel2;
    Left := ScaleX(30);
    Top := ScaleY(30);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '03';
  end;

  NewCheckBox4 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox4 do
  begin
    Parent := SettingPanel2;
    Left := ScaleX(30);
    Top := ScaleY(60);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '04';
  end;

  SettingButton3 := TNewButton.Create(WizardForm);
  with SettingButton3 do
  begin
    Parent := SettingPanel2;
    Left := ScaleX(5);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 1';
    OnClick     := @SettingButtonClick;
  end;

  SettingButton4 := TNewButton.Create(WizardForm);
  with SettingButton4 do
  begin
    Parent := SettingPanel2;
    Left := ScaleX(212);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 3';
    OnClick     := @SettingButtonClick;
  end;

//==============================================//

  SettingPanel3 := TPanel.Create(WizardForm);
  with SettingPanel3 do
  begin
    Parent := ComponentPage.Surface;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(417);
    Height := ScaleY(237);
    BevelOuter := bvNone;
    Caption := 'Страница 3';
  end;

  NewCheckBox5 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox5 do
  begin
    Parent := SettingPanel3;
    Left := ScaleX(30);
    Top := ScaleY(30);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '05';
  end;

  NewCheckBox6 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox6 do
  begin
    Parent := SettingPanel3;
    Left := ScaleX(30);
    Top := ScaleY(60);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := '06';
  end;

  SettingButton5 := TNewButton.Create(WizardForm);
  with SettingButton5 do
  begin
    Parent := SettingPanel3;
    Left := ScaleX(5);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 1';
    OnClick     := @SettingButtonClick;
  end;

  SettingButton6 := TNewButton.Create(WizardForm);
  with SettingButton6 do
  begin
    Parent := SettingPanel3;
    Left := ScaleX(212);
    Top := ScaleY(210);
    Width := ScaleX(200);
    Height := ScaleY(23);
    Caption := 'Перейти на страницу 2';
    OnClick     := @SettingButtonClick;
  end;
end;
 
Сверху