TLama

Untitled

Jul 24th, 2014
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.58 KB | None | 0 0
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5.  
  6. [Code]
  7. var
  8.   EditIndex: Integer;
  9.   InputPage: TInputQueryWizardPage;
  10.  
  11. procedure MyEditChange(Sender: TObject);
  12. begin
  13.   // enable the next button if the edit box is not empty; disable otherwise
  14.   WizardForm.NextButton.Enabled := InputPage.Edits[EditIndex].Text <> '';
  15. end;
  16.  
  17. procedure MyEditKeyPress(Sender: TObject; var Key: Char);
  18. var
  19.   KeyCode: Integer;
  20. begin
  21.   KeyCode := Ord(Key);
  22.   if not ((KeyCode = 8) or ((KeyCode >= 48) and (KeyCode <= 57))) then
  23.     Key := #0;
  24. end;
  25.  
  26. procedure InitializeWizard;
  27. begin
  28.   // create the input query page
  29.   InputPage := CreateInputQueryPage(wpWelcome, 'Caption', 'Description', 'SubCaption');
  30.   // add an edit box and remember its index; False means it is not a password edit
  31.   EditIndex := InputPage.Add('Some value:', False);
  32.   // bind events to the just added edit box
  33.   InputPage.Edits[EditIndex].OnChange := @MyEditChange;
  34.   InputPage.Edits[EditIndex].OnKeyPress := @MyEditKeyPress;
  35. end;
  36.  
  37. procedure CurPageChanged(CurPageID: Integer);
  38. begin
  39.   // if the currently turned wizard page is the one with the edit box, enable
  40.   // the next button if the edit box is not empty; disable otherwise
  41.   if CurPageID = InputPage.ID then
  42.     WizardForm.NextButton.Enabled := InputPage.Edits[EditIndex].Text <> '';
  43. end;
  44.  
  45. procedure CurStepChanged(CurStep: TSetupStep);
  46. begin
  47.   // if the installation has just finished, save the edit box text into a file
  48.   if CurStep = ssPostInstall then
  49.     SaveStringToFile('C:\File.txt', InputPage.Edits[EditIndex].Text, False);
  50. end;
Advertisement
Add Comment
Please, Sign In to add comment