Inno Setup BrowseForFolder dialog with Address bar - inno-setup

When I use the BrowseForFolder function in Inno Setup I get a dialog like this
Is it possible to get a dialog with an address bar such as this one?

Use the TInputDirWizardPage (CreateInputDirPage), instead of using the BrowseForFolder function.
The page has the browse dialog as you want (actually I assume your second screenshot shows this dialog).
If you do not want to add a new page, just create a fake one and abuse it.
var
FakePage: TInputDirWizardPage;
procedure BrowseForFolderEx(var Directory: String);
begin
FakePage.Values[0] := Directory;
FakePage.Buttons[0].OnClick(FakePage.Buttons[0]);
Directory := FakePage.Values[0];
end;
procedure InitializeWizard();
begin
FakePage :=
CreateInputDirPage(wpWelcome, '', '', '', False, SetupMessage(msgButtonNewFolder));
FakePage.Add('');
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := (PageID = FakePage.ID);
end;

Related

Displaying custom status message while extracting archive in Inno Setup

I have an installation file for my app and it contains the .exe file and a .zip file as well.
What I want is:
Recently I added a code in the [Code] section that is extracting files from zip, But actually, it happened after the installation is done, and the progress bar is 100%, So what I want is to make that code's (unzipping) process work with the progress bar and show the user what is extracting at the moment.
For example: let's say extracting files will take 50% of the progress bar and the rest will take it the code section while it is unzipping, with the state about what is extracting at the moment.
Here is the code:
[Code]
procedure InitializeWizard;
begin
ForceDirectories(ExpandConstant('{localappdata}\folder-A\app\folder-B'))
end;
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure unzip(ZipFile, TargetFldr: variant);
var
shellobj: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists(ZipFile) then begin
if not DirExists(TargetFldr) then
if not ForceDirectories(TargetFldr) then begin
MsgBox('Can not create folder '+TargetFldr+' !!', mbError, MB_OK);
Exit;
end;
shellobj := CreateOleObject('Shell.Application');
SrcFldr := shellobj.NameSpace(ZipFile);
DestFldr := shellobj.NameSpace(TargetFldr);
shellfldritems := SrcFldr.Items;
DestFldr.CopyHere(
shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
unzip(ExpandConstant('{app}\example.zip'),ExpandConstant('{app}\'));
end;
end;
The easiest solution is to use the WizardForm.StatusLabel:
WizardForm.StatusLabel.Caption := 'Extracting...';
For more fancy solution you can use TOutputProgressWizardPage. For an example that even displays a progress bar (though by using a DLL for the extraction), see:
Inno Setup - How to add cancel button to decompressing page?
This post lists more related examples:
Inno Setup: How to modify long running script so it will not freeze GUI?

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

Inno Setup Skip custom page after execution of some scripts

so i am currently trying to modify the setup script,
What i was trying to do was after installing i enter in a custom page, this custom page executes 2 scritps(one for creating the database and the other for creating the tables).
while this is executing i want to display a custom label,and a continuous progress bar.
When the execution finish, i want to go directly to the finish page.
I wanto to also remove the next button.
Is this possible?
For the moment i have the custom page with a constinuous progress bar, this page appears after install.i will then add the label after finishing the progress bar part.
here is my code:
[CODE]
var
Page: TWizardPage;
ProgressBar3: TNewProgressBar;
procedure CreateTheWizardPages;
begin
Page := CreateCustomPage(wpInstalling, 'Base de dados', 'A verificar a base de dados');
ProgressBar3 := TNewProgressBar.Create(Page);
ProgressBar3.Left := 5;
ProgressBar3.Width := Page.SurfaceWidth - 5;
ProgressBar3.Parent := Page.Surface;
ProgressBar3.Style := npbstMarquee;
end;
procedure InitializeWizard();
begin
CreateTheWizardPages;
end;
//check the current page,if page equals to wpSelectCompnets, then we add the method on choose to the combobox fo types of installation
procedure CurPageChanged(CurPageID: Integer);
begin
//msgbox(IntToStr( CurPageID),mbInformation, MB_OK);
if CurPageID = wpSelectComponents then
begin
comboboxTypesInstalacao:=WizardForm.TypesCombo;
WizardForm.TypesCombo.OnChange:=#ComboBoxChange;
end
else if CurPageID = Page.ID then
begin
try
CreateDBAndTables('idontimedb.des');
finally
//close this custom wizard page and go to finish page
end;
end;
end;
Thanks in advance.

Inno how to add <Skip> button for optional wizard page?

I have an optional wizard page of TInputDirWizardPage type.
How to add button which will not validate data and skip if data were not entered?
Did you check the inno help, here you see the available functions on the TInputDirWizardPage
TInputDirWizardPage = class(TWizardPage)
function Add(const APrompt: String): Integer;
property Buttons[Index: Integer]: TNewButton; read;
property Edits[Index: Integer]: TEdit; read;
property PromptLabels[Index: Integer]: TNewStaticText; read;
property SubCaptionLabel: TNewStaticText; read;
property Values[Index: Integer]: String; read write;
end;
I used this way only if i needed a text input on the page. I recommend you to create a complete custom WizardPage, with that you are more flexible. For the creation of the page you can use a designer, I created all my custom pages with the InnoSetup Form Designer. Here you can see it in action http://www.cenadep.org/2012/02/09/innosetup-form-designer/
I've found simple and working solution. Instead of adding additional button to avoid validation of empty path. I've just added default dir creation. in [Dirs] section.
[Dirs]
Name: {code:WrkGetWorkingDir}; Flags: uninsneveruninstall
My application could accept working dir cmdline arg or create default one if it is not specified. So. I just always specifying that cmdline arg and creating that default dir (if user did not changed that path) in installation script.
Hope this will help
procedure OnClickMyButton(Sender: TObject);
begin
MsgBox('OnClickMyButton', mbInformation, MB_OK);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = YourPageID.ID then
begin
MyButton := TButton.Create(YourPageID);
MyButton.Parent := YourPageID.Buttons[0].Parent;
MyButton.Top := YourPageID.Edits[0].Top + YourPageID.Edits[0].Height + 10;
MyButton.Left := YourPageID.Edits[0].Left;
MyButton.Width := 100;
MyButton.Caption := 'My Custom Button';
MyButton.OnClick := #OnClickMyButton;
end;
end;

Resources