2010-06-01 7 views
2

Dans Inno Setup, j'ai créé une page personnalisée avec le code suivant qui a 3 zones de texte.J'ai besoin d'aide dans la page personnalisée de configuration d'inno

Maintenant, je veux valider cette zone de texte sur le formulaire personnalisé cliquez sur le bouton suivant. Si dans text.text = '2121212' un texte est entré par l'utilisateur alors seulement le bouton suivant est activé.

[CustomMessages] 
CustomForm_Caption=CustomForm Caption 
CustomForm_Description=CustomForm Description 
CustomForm_Label1_Caption0=College Name: 
CustomForm_Label2_Caption0=Product Type: 
CustomForm_Label3_Caption0=Product ID: 

[Code] 
var 
    Label1: TLabel; 
    Label2: TLabel; 
    Label3: TLabel; 
    Edit1: TEdit; 
    Edit2: TEdit; 
    Edit3: TEdit; 
    Edit4: TEdit; 
    Edit5: TEdit; 
    Edit6: TEdit; 

{ CustomForm_Activate } 

procedure CustomForm_Activate(Page: TWizardPage); 
begin 
    // enter code here... 


end; 

{ CustomForm_ShouldSkipPage } 

function CustomForm_ShouldSkipPage(Page: TWizardPage): Boolean; 
begin 
    Result := False; 
end; 

{ CustomForm_BackButtonClick } 

function CustomForm_BackButtonClick(Page: TWizardPage): Boolean; 
begin 
    Result := True; 
end; 

{ CustomForm_NextkButtonClick } 

function CustomForm_NextButtonClick(Page: TWizardPage): Boolean; 
begin 
    RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS', 
    'College Name', Edit1.Text); 
    RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS', 
    'Product Type', Edit2.Text); 
    RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS', 
    'Product ID', Edit3.Text); 
    Result := True; 
    end; 

{ CustomForm_CancelButtonClick } 

procedure CustomForm_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean); 
begin 
    // enter code here... 
end; 

{ CustomForm_CreatePage } 

function CustomForm_CreatePage(PreviousPageId: Integer): Integer; 
var 
    Page: TWizardPage; 
begin 
    Page := CreateCustomPage(
    PreviousPageId, 
    ExpandConstant('{cm:CustomForm_Caption}'), 
    ExpandConstant('{cm:CustomForm_Description}') 
); 

{ Label1 } 
    Label1 := TLabel.Create(Page); 
    with Label1 do 
    begin 
    Parent := Page.Surface; 
    Caption := ExpandConstant('{cm:CustomForm_Label1_Caption0}'); 
    Left := ScaleX(16); 
    Top := ScaleY(24); 
    Width := ScaleX(70); 
    Height := ScaleY(13); 
    end; 

    { Label2 } 
    Label2 := TLabel.Create(Page); 
    with Label2 do 
    begin 
    Parent := Page.Surface; 
    Caption := ExpandConstant('{cm:CustomForm_Label2_Caption0}'); 
    Left := ScaleX(17); 
    Top := ScaleY(56); 
    Width := ScaleX(70); 
    Height := ScaleY(13); 
    end; 

    { Label3 } 
    Label3 := TLabel.Create(Page); 
    with Label3 do 
    begin 
    Parent := Page.Surface; 
    Caption := ExpandConstant('{cm:CustomForm_Label3_Caption0}'); 
    Left := ScaleX(17); 
    Top := ScaleY(88); 
    Width := ScaleX(70); 
    Height := ScaleY(13); 
    end; 

    { Edit1 } 
    Edit1 := TEdit.Create(Page); 
    with Edit1 do 
    begin 
    Parent := Page.Surface; 
    Left := ScaleX(115); 
    Top := ScaleY(24); 
    Width := ScaleX(273); 
    Height := ScaleY(21); 
    TabOrder := 0; 
    end; 

    { Edit2 } 
    Edit2 := TEdit.Create(Page); 
    with Edit2 do 
    begin 
    Parent := Page.Surface; 
    Left := ScaleX(115); 
    Top := ScaleY(56); 
    Width := ScaleX(273); 
    Height := ScaleY(21); 
    TabOrder := 1; 
    end; 

    { Edit3 } 
    Edit3 := TEdit.Create(Page); 
    with Edit3 do 
    begin 
    Parent := Page.Surface; 
    Left := ScaleX(115); 
    Top := ScaleY(88); 
    Width := ScaleX(273); 
    Height := ScaleY(21); 
    TabOrder := 2; 
    end; 

    with Page do 
    begin 
    OnActivate := @CustomForm_Activate; 
    OnShouldSkipPage := @CustomForm_ShouldSkipPage; 
    OnBackButtonClick := @CustomForm_BackButtonClick; 
    OnNextButtonClick := @CustomForm_NextButtonClick; 
    OnCancelButtonClick := @CustomForm_CancelButtonClick; 
    end; 

    Result := Page.ID; 
end; 

{ CustomForm_InitializeWizard } 

procedure InitializeWizard(); 
begin 

    CustomForm_CreatePage(wpWelcome); 

end; 

Répondre

10

Cela devrait vous aider à démarrer:

; -- CodeDlg.iss -- 
    ; 
    ; This script shows how to insert custom wizard pages into Setup and how to handle 
    ; these pages. Furthermore it shows how to 'communicate' between the [Code] section 
    ; and the regular Inno Setup sections using {code:...} constants. Finally it shows 
    ; how to customize the settings text on the 'Ready To Install' page. 

    [Setup] 
    AppName=My Program 
    AppVerName=My Program version 1.5 
    DefaultDirName={pf}\My Program 
    DisableProgramGroupPage = yes 
    UninstallDisplayIcon={app}\MyProg.exe 
    OutputDir=userdocs:Inno Setup Examples Output 

    [Files] 
    Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion 

    [CustomMessages] 
    CustomForm_Caption=CustomForm Caption 
    CustomForm_Description=CustomForm Description 
    CustomForm_Label1_Caption0=College Name: 
    CustomForm_Label2_Caption0=Product Type: 
    CustomForm_Label3_Caption0=Product ID: 

    [Code] 
    Var 
    Page: TWizardPage; 
    Label1: TLabel; 
    Label2: TLabel; 
    Label3: TLabel; 
    Edit1: TEdit; 
    Edit2: TEdit; 
    Edit3: TEdit; 
    Edit4: TEdit; 
    Edit5: TEdit; 
    Edit6: TEdit; 

    procedure EdtOnChange (Sender: TObject); 
    Var 
    MyEdit : TEdit; 
    begin 
    MyEdit := TEdit(Sender); 
    if MyEdit.Text = '2121212' then 
     WizardForm.NextButton.Enabled := true 
    Else 
     WizardForm.NextButton.Enabled := false; 
    end; 


    procedure InitializeWizard; 
    Var 
     CheckBox: TCheckBox; 
    begin 
     Page := CreateCustomPage(wpWelcome, ExpandConstant('{cm:CustomForm_Caption}'), ExpandConstant('{cm:CustomForm_Description}')); 


    { Label1 } Label1 := TLabel.Create(Page); with Label1 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label1_Caption0}'); Left := ScaleX(16); Top := ScaleY(24); Width := ScaleX(70); Height := ScaleY(13); end; 

    { Label2 } Label2 := TLabel.Create(Page); with Label2 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label2_Caption0}'); Left := ScaleX(17); Top := ScaleY(56); Width := ScaleX(70); Height := ScaleY(13); end; 

    { Label3 } Label3 := TLabel.Create(Page); with Label3 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label3_Caption0}'); Left := ScaleX(17); Top := ScaleY(88); Width := ScaleX(70); Height := ScaleY(13); end; 

    { Edit1 } Edit1 := TEdit.Create(Page); with Edit1 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(24); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 0; end; 

    { Edit2 } Edit2 := TEdit.Create(Page); with Edit2 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(56); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 1; end; 

    { Edit3 } Edit3 := TEdit.Create(Page); with Edit3 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(88); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 2; end; 

     Edit3.OnChange := @EdtOnChange; 

    end; 

    procedure CurPageChanged(CurPageID: Integer); 
    begin 
    If CurPageID = Page.ID Then 
     WizardForm.NextButton.Enabled := false; 
    end; 

    end. 

Comme il est écrit, il vérifie la troisième zone de texte pour la valeur « 2121212 ». Si vous le souhaitez dans la première ou la deuxième zone, vous souhaitez ajouter un gestionnaire d'événement OnChange pour la zone d'édition appropriée.