How to show password while typing in Inno Setup? - inno-setup

I have created a setup with Inno Setup via Wizard method and used a password. But when I ran setup and in Password screen, password is hidden while typing (****). I want password to be shown while typing.
Can somebody guide me?

Set TPasswordEdit.Password property of WizardForm.PasswordEdit to False:
<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
WizardForm.PasswordEdit.Password := False;
end;
If you want to allow the user to toggle the display of the password, you have to add a custom checkbox.
var
ShowPasswordCheck: TNewCheckBox;
procedure ShowPasswordCheckClick(Sender: TObject);
begin
WizardForm.PasswordEdit.Password := not ShowPasswordCheck.Checked;
end;
<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
ShowPasswordCheck := TNewCheckBox.Create(WizardForm);
ShowPasswordCheck.Parent := WizardForm.PasswordEdit.Parent;
ShowPasswordCheck.Caption := '&Show password';
ShowPasswordCheck.Top :=
WizardForm.PasswordEdit.Top + WizardForm.PasswordEdit.Height + ScaleY(8);
ShowPasswordCheck.Height := ScaleY(ShowPasswordCheck.Height);
ShowPasswordCheck.Checked := not WizardForm.PasswordEdit.Password;
ShowPasswordCheck.OnClick := #ShowPasswordCheckClick;
end;

Related

Create a checkbox to optionally delete files in a custom page at Inno Setup uninstaller

I created custom pages for an uninstaller using this code: How to create a OuterNotebook/welcome page in the Inno Setup uninstaller? and I want to create a checkbox that allows me to optionally delete certain files in a custom page (before the uninstallation process). I am trying to use this code:
NewCheckBox1 := TNewCheckBox.Create(UninstallProgressForm);
with NewCheckBox1 do
begin
Parent := UninstallfirstPage;
Left := NewStaticText1.Left;
Top := NewStaticText1.Top + NewStaticText1.Height + 8;
Width := NewStaticText1.Width;
Height := ScaleY(30);
Caption := 'Eliminar partidas guardadas';
end;
But I do not know how to link this code to the action of removing the additional folder in the uninstallation.
For example:
Just test a value of the checkbox in the CurUninstallStepChanged event function and call DelTree function eventually.
var
NewCheckBox1: TNewCheckBox; // a global variable
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then // or usPostUninstall
begin
if NewCheckBox1.Checked then
begin
Log('Deleting folder');
if DelTree(ExpandConstant('{userappdata}\My Program'), True, True, True) then
begin
Log('Deleted folder');
end
else
begin
MsgBox('Error deleting folder', mbError, MB_OK);
end;
end;
end;
end;

Inno Setup custom wizard pages ("installation checklist") change text at runtime

I made a custom wizard page, and I want it to show a sort of installation checklist at the end of the install, showing what installed successfully or not.
Something like
Crucial Step......................SUCCESS
Optional Step.....................FAILURE
So I have this code in my initializeWizard()
Page := CreateCustomPage(wpInstalling, 'Installation Checklist', 'Status of all installation components');
RichEditViewer := TRichEditViewer.Create(Page);
RichEditViewer.Width := Page.SurfaceWidth;
RichEditViewer.Height := Page.SurfaceHeight;
RichEditViewer.Parent := Page.Surface;
RichEditViewer.ScrollBars := ssVertical;
RichEditViewer.UseRichEdit := True;
RichEditViewer.RTFText := ''// I want this attribute to be set in CurStepChanged()
Is there a way to add or edit RichEditViewer.RTFText at a later point in time? Page is a global variable but trying to access any attributes gives me an error. I'd like to do edit the text after wpInstalling, so I can tell whether or not install steps were successful.
I'm not a huge fan of this method, but you Can set your RichEditViewer as a global, and then editing it at any point, in any function, is trivial.
var
RichEditViewer: TRichEditViewer;
procedure InitializeWizard();
var
Page: TWizardPage;
begin
Page := CreateCustomPage(wpInstalling, 'Installation Checklist', '');
RichEditViewer := TRichEditViewer.Create(Page);
RichEditViewer.Width := Page.SurfaceWidth;
RichEditViewer.Height := Page.SurfaceHeight;
RichEditViewer.Parent := Page.Surface;
RichEditViewer.ScrollBars := ssVertical;
RichEditViewer.UseRichEdit := True;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep=ssPostInstall then RichEditViewer.RTFText := 'STUFF';
end;
Worthwhile to note, the page itself doesn't even need to be global.

Inno Setup disable Installing Wizard Pages

Is it possible to disable the the Preparing To Install wpPreparing and the Installing wpInstalling Wizard Pages (i.e. the ones with the progress bar) so that they do not show during installation? There does not appear to be a built-in directive or method (e.g. for the Ready Wizard Page you can use DisableReadyPage=yes to do so). Am I missing something, or is it, as I suspect, simply not possible?
I have already tried using:
function ShouldSkipPage(CurPageID: Integer): Boolean;
begin
if CurPageID = wpPreparing then
Result := True;
if CurPageID = wpInstalling then
Result := True;
end;
Have you tried this - DisableReadyPage=yes in the [Setup] section.
Seems the only other option is to use the "install silently" command line switch. I'd be careful though this essentially installs a potentially destructive program without the users knowledge.
It is not possible to skip the wpPreparing or wpInstalling Wizard Pages. However, if the installer is not actually installing anything and is being used to return something, say an unlock code, as is the use case here, the following could be done instead:
//Disable the Exit confirmation prompt
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Cancel := True;
Confirm := False;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
//Get the unlock code
if CurPageID = UnlockCodePage.ID then
begin
if UnlockCodePage.Values[0] = '' then
begin
MsgBox('You must enter an installation ID to generate an unlock code.',
mbError, MB_OK);
end
else
begin
UnlockCodePage.Values[1] := GetUnlockCode;
end;
Result := False;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
//Define button visibility, whether the Back button is enabled and change the Next and Cancel button labels
WizardForm.CancelButton.Caption := '&Close';
if CurPageID = UnlockCodePage.ID then
begin
WizardForm.BackButton.Enabled := False;
WizardForm.NextButton.Caption := '&Generate';
end;
end;
Hopefully this may help someone looking to do something similar.

Show text during installation process with inno-setup

I am searching for a possibility to show a user a note on how to proceed during install of a redistributable.
Background:
I have some Components that require 3rd party installations which are quit complex. If a user selects one of these components a message box with instructions are shown. After this box the resistributables are executet via exec/shellExec with 'ewWaitUntilTerminated'. Unfortunately the user cannot see the box during installation.
I tried to just open the notes in notepad and use 'ewNoWait', but than it will not close automatically after each installation of the redistributalbe. The user can chose more than one of these components and this help should only be visible during the specific installation. To kill the notepad with taskkill is not an option, it could kill opened notepad from the user.
Is there any elegant way to get such behaviour?
Create TOutputProgressWizardPage with function http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_createoutputprogresspage
function CreateOutputProgressPage(const ACaption, ADescription: String): TOutputProgressWizardPage;
[Code]
var
ProgressPage: TOutputProgressWizardPage;
procedure InitializeWizard;
begin
ProgressPage := CreateOutputProgressPage('Finalization of installation','');
end;
procedure CurPageChanged(CurPageID: Integer);
var
I: Integer;
begin
// Page is shown after installation when Finish page is shown
if CurPageID = wpFinish then begin
ProgressPage.SetText('Installing some 3rd party stuff...', '');
ProgressPage.SetProgress(0, 0);
ProgressPage.Show;
try
// Use exec/shellExec here to execute 3rd party app
// Also you can adjust progress barr position here:
for I := 0 to 10 do begin
ProgressPage.SetProgress(I, 10);
Sleep(100);
end;
finally
ProgressPage.Hide;
end;
end else
Result := True;
end;
I finally found a solution for my problem. On the basis of the answer of Slappy I used a std MsgPage and resize it for my need. Thx to TLama for his answer in a different topic for the resize code!
[Code]
var
RedistPage: TOutputMsgWizardPage;
DefaultTop,
DefaultLeft,
DefaultHeight,
DefaultBackTop,
DefaultNextTop,
DefaultCancelTop,
DefaultBevelTop,
DefaultBeveledLabelTop,
DefaultInnerHeight,
DefaultOuterHeight: Integer;
procedure InitializeWizard();
var
ReadMe: AnsiString;
begin
DefaultTop := WizardForm.Top;
DefaultLeft := WizardForm.Left;
DefaultHeight := WizardForm.Height;
DefaultBackTop := WizardForm.BackButton.Top;
DefaultNextTop := WizardForm.NextButton.Top;
DefaultCancelTop := WizardForm.CancelButton.Top;
DefaultBevelTop := WizardForm.Bevel.Top;
DefaultBeveledLabelTop := WizardForm.BeveledLabel.Top;
DefaultOuterHeight := WizardForm.OuterNotebook.Height;
DefaultInnerHeight := WizardForm.InnerNotebook.Height;
// save the contents of Readme.txt (non Unicode) in a string and build custom page
try
ExtractTemporaryFiles('{tmp}\readme.txt');
if LoadStringFromFile(ExpandConstant('{tmp}\readme.txt'), ReadMe) then
RedistPage := CreateOutputMsgPage(wpReady,
'Information', 'Please read the following important information about the installation before continuing.',ReadMe);
except
ShowExceptionMessage;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False; // initialize result to not skip any page (not necessary, but safer)
if PageID = RedistPage.ID then // if the page that is asked to be skipped is your custom page, then...
Result := not IsTaskSelected('dexela_API'); // if the task is not selected, skip the page
end;
procedure ChangePageSize(HeightOffset: Integer);
begin
WizardForm.Top := DefaultTop - (HeightOffset - DefaultHeight) div 2;
WizardForm.Height := WizardForm.Height + (HeightOffset - DefaultHeight);
WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (HeightOffset - DefaultHeight);
WizardForm.InnerNotebook.Height := WizardForm.InnerNotebook.Height + (HeightOffset - DefaultHeight);
WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (HeightOffset - DefaultHeight);
WizardForm.CancelButton.Top := DefaultCancelTop + (HeightOffset - DefaultHeight);
WizardForm.NextButton.Top := DefaultNextTop + (HeightOffset - DefaultHeight);
WizardForm.BackButton.Top := DefaultBackTop + (HeightOffset - DefaultHeight);
WizardForm.Bevel.Top := DefaultBevelTop + (HeightOffset - DefaultHeight);
end;
procedure CurPageChanged(CurPageID: Integer);
var
ComponentsPageTextHeight: Integer;
begin
if (CurPageID = RedistPage.ID) and (IsTaskSelected('dexela_API'))then begin
ChangePageSize(650);
//Sleep(2000); // time for the user to recognize the text, before it is hidden by installer
// Extract all Dexela files and launch them.
try
ExtractTemporaryFiles('{tmp}\Setup.msi');
except
ShowExceptionMessage;
end;
ShellExec('',ExpandConstant('{tmp}\Setup.msi'), '', '',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;

How to change the Next/Cancel button captions on a custom page?

How to change the Next/Cancel button captions on a custom page ?
You can use:
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = YourPageName.ID then begin
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall);
//or := 'YourNewNextButtonText' or := ExpandConstant('{cm:YourCmTitleForNext}')
WizardForm.CancelButton.Caption := ExpandConstant('{cm:YourCmTitleForCancel}');
end; //begin + end to make changes only for this single page
end;

Resources