Why is my Delphi code not executing in order? - image

I am creating a program, and I need to display an image and then block input for a few seconds before allowing it again. The problem I am running into is that Delphi is not running the code in order and is executing the Sleep() command before the image command. I have run into this problem before when using Sleep() with a video before displaying a message.
The code looks as follows:
procedure TtForm.WindowsMediaPlayer2Click(ASender: TObject;
nButton, nShiftState: SmallInt; fX, fY: Integer);
Var
buttonSelected: Integer;
begin
buttonSelected := MessageDlg('Well done Monkey!-_-', mtError, mbOKCancel, 0);
if buttonSelected = mrOK then
begin
Pages.Visible := False;
WindowsMediaPlayer2.Visible := False;
imgEroor.BringToFront;
BorderStyle := bsNone;
WindowState := wsMaximized;
imgEroor.Top := 0;
imgEroor.Left := 0;
imgEroor.Width := Screen.Width;
imgEroor.Height := Screen.Height;
imgEroor.BringToFront;
BlockInput(True);
Sleep(10000);
BlockInput(False);
end;
if buttonSelected = mrCancel then
begin
Pages.Visible := False;
WindowsMediaPlayer2.Visible := False;
imgEroor.BringToFront;
BorderStyle := bsNone;
WindowState := wsMaximized;
imgEroor.Top := 0;
imgEroor.Left := 0;
imgEroor.Width := Screen.Width;
imgEroor.Height := Screen.Height;
imgEroor.BringToFront;
BlockInput(True);
Sleep(10000);
BlockInput(False);
end;
end;

Related

Colours of controls on custom wizard page are not correct on Windows 7 - Parallels (Inno Script)

Context:
MacBook Pro (latest Big Sur 11.1)
Parallels (latest)
Windows 7 (all updates)
When I run my setup, my custom page looks like this:
Some text is showing black. This issue does not happen when you run my installer on native Windows 10 on a PC.
My custom page is designed like this:
// ================================================
// Automatic Backup Settings Page
// ================================================
[Code]
{ Constants }
const
BackupWhat_None = 0;
BackupWhat_Complete = 1;
BackupWhat_Essential = 2;
BackupMode_Automatic = 0;
BackupMode_Manual = 1;
BackupPrompt_Never = 0;
BackupPrompt_Daily = 1;
BackupPrompt_Weekly = 2;
BackupPrompt_Monthly = 3;
{ Global Variables }
var
pageAutoBackup: TWizardPage;
pnlBackupWhat: TPanel;
lblBackupWhat: TLabel;
radBackupWhatNone: TNewRadioButton;
radBackupWhatComplete: TNewRadioButton;
radBackupWhatEssential: TNewRadioButton;
lblBackupMode: TLabel;
pnlBackupMode: TPanel;
radBackupModeAuto: TNewRadioButton;
radBackupModeManual: TNewRadioButton;
lblPromptMode: TLabel;
cmbPromptMode: TNewComboBox;
lblBackupFolder: TLabel;
txtBackupFolder: TNewEdit;
btnSelectBackupFolder: TNewButton;
{ Sets the state of the controls }
procedure EnableAutoBackupSettingPageControls();
var
bEnable: Boolean;
begin
bEnable := radBackupWhatComplete.Checked or radBackupWhatEssential.Checked
pnlBackupMode.Enabled := bEnable;
lblBackupMode.Enabled := bEnable;
radBackupModeAuto.Enabled := bEnable;
radBackupModeManual.Enabled := bEnable;
lblPromptMode.Enabled := bEnable;
cmbPromptMode.Enabled := bEnable;
lblBackupFolder.Enabled := bEnable;
txtBackupFolder.Enabled := bEnable;
btnSelectBackupFolder.Enabled := bEnable;
if(radBackupWhatNone.Checked = True) then
Wizardform.NextButton.Enabled := True
else
Wizardform.NextButton.Enabled := DirExists(txtBackupFolder.Text);
WizardForm.Update;
end;
{ Ask user to select the backup Folder location }
procedure btnSelectBackupFolder_Click(Sender: TObject);
var
strFolder: string;
begin
strFolder := txtBackupFolder.Text;
{ Display Browse Window }
if(BrowseForFolder('', strFolder, True)) then
begin
txtBackupFolder.Text := strFolder;
Wizardform.NextButton.Enabled := DirExists(txtBackupFolder.Text);
WizardForm.Update;
end;
end;
{ Action handler }
procedure radBackupWhat_Click(Sender: TObject);
begin
{ Set control states }
EnableAutoBackupSettingPageControls();
end;
{ Automatic Backup Settings Custom Page }
function pageAutoBackup_CreatePage(PreviousPageId: Integer): Integer;
var
iButtonGap: Integer;
begin
{ Create the page }
pageAutoBackup := CreateCustomPage(PreviousPageId,
ExpandConstant('{cm:pageAutoBackupTitle}'),
ExpandConstant('{cm:pageAutoBackupDescription}'));
{ pnlBackupWhat (TPanel) }
pnlBackupWhat := TPanel.Create(pageAutoBackup);
pnlBackupWhat.Caption := '';
pnlBackupWhat.BevelOuter := bvNone;
pnlBackupWhat.BevelInner := bvNone; { default }
pnlBackupWhat.BevelKind := bkNone;
pnlBackupWhat.Parent := pageAutoBackup.Surface;
pnlBackupWhat.Enabled := True;
pnlBackupWhat.Visible := True;
pnlBackupWhat.Left := ScaleX(0);
pnlBackupWhat.Top := ScaleY(0);
pnlBackupWhat.Width := pageAutoBackup.Surface.Width;
pnlBackupWhat.Anchors := [akLeft, akRight];
{ lblBackupWhat (TLabel) }
lblBackupWhat := TLabel.Create(pageAutoBackup);
lblBackupWhat.Parent := pnlBackupWhat;
lblBackupWhat.Enabled := True;
lblBackupWhat.Visible := True;
lblBackupWhat.Width := pnlBackupWhat.Width;
lblBackupWhat.Caption := ExpandConstant('{cm:lblBackupWhat}');
{ radBackupWhatNone (TNewRadioButton) }
radBackupWhatNone := TNewRadioButton.Create(pageAutoBackup);
radBackupWhatNone.Parent := pnlBackupWhat;
radBackupWhatNone.Enabled := True;
radBackupWhatNone.Visible := True;
radBackupWhatNone.Top := lblBackupWhat.Top + lblBackupWhat.Height + ScaleY(2);
radBackupWhatNone.Width := pnlBackupWhat.Width;
radBackupWhatNone.Height := ScaleY(radBackupWhatNone.Height);
radBackupWhatNone.Checked := False;
radBackupWhatNone.Caption := ExpandConstant('{cm:radBackupWhatNone}');
radBackupWhatNone.OnClick := #radBackupWhat_Click;
{ radBackupWhatComplete (TNewRadioButton) }
radBackupWhatComplete := TNewRadioButton.Create(pageAutoBackup);
radBackupWhatComplete.Parent := pnlBackupWhat;
radBackupWhatComplete.Enabled := True;
radBackupWhatComplete.Visible := True;
radBackupWhatComplete.Top := radBackupWhatNone.Top + radBackupWhatNone.Height + ScaleY(2);
radBackupWhatComplete.Width := pnlBackupWhat.Width;
radBackupWhatComplete.Height := ScaleY(radBackupWhatComplete.Height);
radBackupWhatComplete.Checked := False;
radBackupWhatComplete.Caption := ExpandConstant('{cm:radBackupWhatComplete}');
radBackupWhatComplete.OnClick := #radBackupWhat_Click;
{ radBackupWhatEssential (TNewRadioButton) }
radBackupWhatEssential := TNewRadioButton.Create(pageAutoBackup);
radBackupWhatEssential.Parent := pnlBackupWhat;
radBackupWhatEssential.Enabled := True;
radBackupWhatEssential.Visible := True;
radBackupWhatEssential.Top := radBackupWhatComplete.Top + radBackupWhatComplete.Height + ScaleY(2);
radBackupWhatEssential.Width := pnlBackupWhat.Width;
radBackupWhatEssential.Height := ScaleY(radBackupWhatEssential.Height);
radBackupWhatEssential.Checked := False;
radBackupWhatEssential.Caption := ExpandConstant('{cm:radBackupWhatEssential}');
radBackupWhatEssential.OnClick := #radBackupWhat_Click;
{ Now we can set the panel height! }
pnlBackupWhat.ClientHeight :=
radBackupWhatEssential.Top + radBackupWhatEssential.Height + ScaleY(5);
{ pnlBackupMode (TPanel) }
pnlBackupMode := TPanel.Create(pageAutoBackup);
pnlBackupMode.Caption := '';
pnlBackupMode.BevelOuter := bvNone;
pnlBackupMode.BevelInner := bvNone; { default }
pnlBackupMode.BevelKind := bkNone;
pnlBackupMode.Parent := pageAutoBackup.Surface;
pnlBackupMode.Enabled := True;
pnlBackupMode.Visible := True;
pnlBackupMode.Top := pnlBackupWhat.Top + pnlBackupWhat.Height + ScaleY(2);
pnlBackupMode.Width := pageAutoBackup.Surface.Width;
pnlBackupMode.Height := ScaleY(100);
pnlBackupMode.Anchors := [akLeft, akRight];
{ lblBackupMode (TLabel) }
lblBackupMode := TLabel.Create(pageAutoBackup);
lblBackupMode.Parent := pnlBackupMode;
lblBackupMode.Enabled := True;
lblBackupMode.Visible := True;
lblBackupMode.Width := pnlBackupMode.Width;
lblBackupMode.Caption := ExpandConstant('{cm:lblBackupMode}');
{ radBackupModeAuto (TNewRadioButton) }
radBackupModeAuto := TNewRadioButton.Create(pageAutoBackup);
radBackupModeAuto.Parent := pnlBackupMode;
radBackupModeAuto.Enabled := True;
radBackupModeAuto.Visible := True;
radBackupModeAuto.Left := ScaleX(0);
radBackupModeAuto.Top := lblBackupMode.Top + lblBackupMode.Height + ScaleY(2);
radBackupModeAuto.Width := pnlBackupMode.Width;
radBackupModeAuto.Height := ScaleY(radBackupModeAuto.Height);
radBackupModeAuto.Checked := False;
radBackupModeAuto.Caption := ExpandConstant('{cm:radBackupModeAuto}');
{ radBackupModeManual (TNewRadioButton) }
radBackupModeManual := TNewRadioButton.Create(pageAutoBackup);
radBackupModeManual.Parent := pnlBackupMode;
radBackupModeManual.Enabled := True;
radBackupModeManual.Visible := True;
radBackupModeManual.Top := radBackupModeAuto.Top + radBackupModeAuto.Height + ScaleY(2);
radBackupModeManual.Width := pnlBackupMode.Width;
radBackupModeManual.Height := ScaleY(radBackupModeManual.Height);
radBackupModeManual.Checked := False;
radBackupModeManual.Caption := ExpandConstant('{cm:radBackupModeManual}');
{ lblPromptMode (TLabel) }
lblPromptMode := TLabel.Create(pageAutoBackup);
lblPromptMode.Parent := pnlBackupMode;
lblPromptMode.Enabled := True;
lblPromptMode.Visible := True;
lblPromptMode.Top := radBackupModeManual.Top + radBackupModeManual.Height + ScaleY(10);
lblPromptMode.Width := pnlBackupMode.Width;
lblPromptMode.Caption := ExpandConstant('{cm:lblPromptMode}');
{ cmbPromptMode (TNewComboBox) }
cmbPromptMode := TNewComboBox.Create(pageAutoBackup);
cmbPromptMode.Parent := pnlBackupMode;
cmbPromptMode.Style := csDropDownList;
cmbPromptMode.Enabled := True;
cmbPromptMode.Visible := True;
cmbPromptMode.Top := lblPromptMode.Top + lblPromptMode.Height + ScaleY(5);
cmbPromptMode.Width := pnlBackupMode.Width;
cmbPromptMode.ItemIndex := 0;
cmbPromptMode.Items.Add(ExpandConstant('{cm:cmbPromptModeItemNever}'));
cmbPromptMode.Items.Add(ExpandConstant('{cm:cmbPromptModeItemDaily}'));
cmbPromptMode.Items.Add(ExpandConstant('{cm:cmbPromptModeItemWeekly}'));
cmbPromptMode.Items.Add(ExpandConstant('{cm:cmbPromptModeItemMonthly}'));
cmbPromptMode.Anchors := [akLeft, akRight];
{ Now we can set the panel height! }
pnlBackupMode.ClientHeight :=
(cmbPromptMode.Top + cmbPromptMode.Height) + ScaleY(5);
{ lblBackupFolder (TLabel) }
lblBackupFolder := TLabel.Create(pageAutoBackup);
lblBackupFolder.Parent := pageAutoBackup.Surface;
lblBackupFolder.Enabled := True;
lblBackupFolder.Visible := True;
lblBackupFolder.Top := pnlBackupMode.Top + pnlBackupMode.Height + ScaleY(2);
lblBackupFolder.Width := pnlBackupMode.Width;
lblBackupFolder.Caption := ExpandConstant('{cm:lblBackupFolder}');
lblBackupFolder.Anchors := [akLeft, akRight, akBottom];
{ txtBackupFolder (TNewEdit) }
txtBackupFolder := TNewEdit.Create(pageAutoBackup);
txtBackupFolder.Parent := pageAutoBackup.Surface;
txtBackupFolder.Enabled := True;
txtBackupFolder.ReadOnly := True;
txtBackupFolder.Visible := True;
txtBackupFolder.Top := lblBackupFolder.Top + lblBackupFolder.Height + ScaleY(5);
txtBackupFolder.Anchors := [akLeft, akRight, akBottom];
{ btnSelectBackupFolder (TNewButton) }
btnSelectBackupFolder := TNewButton.Create(pageAutoBackup);
btnSelectBackupFolder.Parent := pageAutoBackup.Surface;
btnSelectBackupFolder.Enabled := True;
btnSelectBackupFolder.Visible := True;
btnSelectBackupFolder.Left := pageAutoBackup.Surface.Width - WizardForm.CancelButton.Width;
btnSelectBackupFolder.Top := txtBackupFolder.Top;
btnSelectBackupFolder.Width := WizardForm.CancelButton.Width;
btnSelectBackupFolder.Height := WizardForm.CancelButton.Height;
btnSelectBackupFolder.Caption := SetupMessage(msgButtonBrowse);
btnSelectBackupFolder.Anchors := [akRight, akBottom];
btnSelectBackupFolder.OnClick := #btnSelectBackupFolder_Click;
{ Now we can set the text box width!
Use the gap between the Next and Cancel buttons for consistency.}
iButtonGap := WizardForm.CancelButton.Left -
(WizardForm.NextButton.Left + WizardForm.NextButton.Width);
txtBackupFolder.Width :=
pageAutoBackup.Surface.Width - btnSelectBackupFolder.Width - iButtonGap;
Result := pageAutoBackup.ID;
end;
function GetWhatToBackupMode(Param: string): string;
begin
if(radBackupWhatComplete.Checked) then
begin
Log('What to backup: Complete backup mode selected.');
Result := IntToStr(BackupWhat_Complete);
end
else if(radBackupWhatEssential.Checked) then
begin
Log('What to backup: Essential backup mode selected.');
Result := IntToStr(BackupWhat_Essential);
end
else begin
Log('What to backup: No backup mode selected.');
Result := IntToStr(BackupWhat_None);
end;
end;
function GetHowToBackupMode (Param: string): string;
begin
if(radBackupModeManual.Checked) then
begin
Log('How to backup: Perform the backup manually.');
Result := IntToStr(BackupMode_Manual);
end
else begin
Log('How to backup: Perform the backup automatically.');
Result := IntToStr(BackupMode_Automatic);
end;
end;
function GetBackupPromptMode (Param: string): string;
begin
Log('Where to backup: ' + cmbPromptMode.Items[cmbPromptMode.ItemIndex]);
Result := IntToStr(cmbPromptMode.ItemIndex);
end;
function GetBackupLocationPath (Param: string): string;
begin
// If empty, use the app folder and create a backup folder (Param)
Log(txtBackupFolder.Text);
Result := txtBackupFolder.Text;
end;
procedure AutoBackupPage_InitializeWizard(AfterId: Integer);
var
dwBackupAtShutdownWhat: Cardinal;
dwBackupAtShutdownHow: Cardinal;
dwBackupPromptMode: Cardinal;
strBackupFolder: String;
begin
pageAutoBackup_CreatePage(AfterId);
{ What to Backup }
dwBackupAtShutdownWhat := BackupWhat_None;
if (IsWin64) then
begin
RegQueryDWordValue(HKLM64,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownWhat', dwBackupAtShutdownWhat)
end else
begin
RegQueryDWordValue(HKLM,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownWhat', dwBackupAtShutdownWhat);
end;
if (dwBackupAtShutdownWhat = BackupWhat_Complete) then
begin
radBackupWhatComplete.Checked := True;
end
else if (dwBackupAtShutdownWhat = BackupWhat_Essential) then
begin
radBackupWhatEssential.Checked := True;
end
else begin
radBackupWhatNone.Checked := True;
end;
{ How to Backup }
dwBackupAtShutdownHow := BackupMode_Automatic;
if (IsWin64) then
begin
RegQueryDWordValue(HKLM64,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownMode', dwBackupAtShutdownHow);
end else
begin
RegQueryDWordValue(HKLM,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownMode', dwBackupAtShutdownHow);
end;
if (dwBackupAtShutdownHow = BackupMode_Manual) then
begin
radBackupModeManual.Checked := True;
end
else begin
radBackupModeAuto.Checked := True;
end;
{ Backup Prompt Mode }
dwBackupPromptMode := BackupPrompt_Never;
if (IsWin64) then
begin
RegQueryDWordValue(HKLM64,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupPromptMode', dwBackupPromptMode);
end else
begin
RegQueryDWordValue(HKLM,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupPromptMode', dwBackupPromptMode);
end;
cmbPromptMode.ItemIndex := dwBackupPromptMode;
{ Backup Local Path }
strBackupFolder := '';
if (IsWin64) then
begin
RegQueryStringValue(HKLM64,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownLocalPath', strBackupFolder);
end else
begin
RegQueryStringValue(HKLM,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownLocalPath', strBackupFolder);
end;
{ Do we need to reset the existing folder? }
if(not DirExists(strBackupFolder)) then strBackupFolder := '';
txtBackupFolder.Text := strBackupFolder;
end;
procedure AutoBackupPage_CurPageChanged(CurPageID: Integer);
begin
if CurPageID = pageAutoBackup.ID then
begin
{ Get the state of the Next button correct }
if(radBackupWhatNone.Checked) then
Wizardform.NextButton.Enabled := True
else
Wizardform.NextButton.Enabled := DirExists(txtBackupFolder.Text);
WizardForm.Update;
end;
end;
{ Build the Memo text for the Auto Backup Settings page }
function AutoBackupPage_MemoInfo(Space, NewLine: String): String;
begin
Result := Result + ExpandConstant('{cm:pageAutoBackupTitle}') + NewLine;
{ What to Backup }
Result := Result + Space + ExpandConstant('{cm:lblBackupWhat}') + NewLine;
if(radBackupWhatNone.Checked) then
Result := Result + Space + Space + ExpandConstant('{cm:radBackupWhatNone}') + NewLine;
if(radBackupWhatComplete.Checked) then
Result := Result + Space + Space + ExpandConstant('{cm:radBackupWhatComplete}') + NewLine;
if(radBackupWhatEssential.Checked) then
Result := Result + Space + Space + ExpandConstant('{cm:radBackupWhatEssential}') + NewLine;
if(radBackupWhatNone.Checked = False) then
begin
{ How to Backup }
Result := Result + Space + ExpandConstant('{cm:lblBackupMode}') + NewLine;
if(radBackupModeAuto.Checked) then
Result := Result + Space + Space + ExpandConstant('{cm:radBackupModeAuto}') + NewLine;
if(radBackupModeManual.Checked) then
Result := Result + Space + Space + ExpandConstant('{cm:radBackupModeManual}') + NewLine;
{ Prompt Mode }
Result := Result + Space + Space + ExpandConstant('{cm:lblPromptMode}') + NewLine;
if(cmbPromptMode.ItemIndex = BackupPrompt_Never) then
Result := Result + Space + Space + Space + ExpandConstant('{cm:cmbPromptModeItemNever}') + NewLine;
if(cmbPromptMode.ItemIndex = BackupPrompt_Daily) then
Result := Result + Space + Space + Space + ExpandConstant('{cm:cmbPromptModeItemDaily}') + NewLine;
if(cmbPromptMode.ItemIndex = BackupPrompt_Weekly) then
Result := Result + Space + Space + Space + ExpandConstant('{cm:cmbPromptModeItemWeekly}') + NewLine;
if(cmbPromptMode.ItemIndex = BackupPrompt_Monthly) then
Result := Result + Space + Space + Space + ExpandConstant('{cm:cmbPromptModeItemMonthly}') + NewLine;
{ Backup Folder }
Result := Result + Space + ExpandConstant('{cm:lblBackupFolder}') + NewLine;
Result := Result + Space + Space + txtBackupFolder.Text + NewLine;
end;
Result := Result + NewLine;
end;
I am using skinning as you can see (#define Skin "Amakrits.vsf").
I didn't anticipate this rendering issue.
Works fine for me on latest Win 10.
Your picture shows you have selected "Don't perform..." option which disables the controls in next group, that is a reason why the controls have different colors.
Did you make any changes in the skin file Amakrits.vsf? My skin looks different (I downloaded it from GitHub few moments ago) and it looks like some tweaks are missing in my case.
Conclusion: this is not an Inno Setup issue, but problem in VCL skinning plugin (try to post your issue here: https://github.com/RRUZ/vcl-styles-plugins/issues), but it looks like it can be improved by tweaking the colors in used .vsf file.
P.S. your script could not be compiled correctly as there were missing Custom Messages and skin / setup initialization functions.

FireDAC under connecting freeze GUI

I'm facing with an issue, here is my code
constructor TORAThread.Create;
begin
inherited Create(True);
ORAFDcon_Ora := TFDConnection.Create(nil);
ORAFDPhysOracleDriverLink := TFDPhysOracleDriverLink.Create(nil);
ORAFDGUIxWaitCursor := TFDGUIxWaitCursor.Create(nil);
ORAStorPRoc := TFDStoredProc.Create(nil);
ORAFDcon_Ora.DriverName := 'ora';
ORAFDcon_Ora.LoginPrompt := False;
ORAFDcon_Ora.Params.LoadFromFile('ORAconfig.ini');
ORAFDcon_Ora.CheckConnectionDef;
ORAFDcon_Ora.ResourceOptions.AutoConnect := True;
ORAFDcon_Ora.ResourceOptions.AutoReconnect := True;
ORAFDcon_Ora.ResourceOptions.KeepConnection := True;
ORAFDcon_Ora.ResourceOptions.CmdExecMode := amNonBlocking;
procedure TORAThread.Execute;
begin
ORAFDcon_Ora.Connected := True;
while not terminated do
begin
//somejobs
end;
When I start the thread and VPN connection is not alive, my GUI freezes
Whats wrong?
Regards,

Inno Setup - How to change a label caption [or other controls in general], when selected value in combox box changes

When changing a language in combo box (without clicking ok), I want to change texts of the dialog (label, form caption, button caption)
procedure SelectLanguage();
var
LanguageForm: TSetupForm;
CancelButton: TNewButton;
OKButton: TNewButton;
LangCombo: TNewComboBox;
SelectLabel: TNewStaticText;
Languages: TStrings;
Params: string;
Instance: THandle;
P, I: Integer;
S, L: string;
begin
Languages := TStringList.Create();
Languages.Add('en=English');
Languages.Add('cs='+#$010C+'e'+#$0161+'tina');
LanguageForm := CreateCustomForm;
LanguageForm.Caption := SetupMessage(msgSelectLanguageTitle);
LanguageForm.ClientWidth := ScaleX(297);
LanguageForm.ClientHeight := ScaleY(125);
LanguageForm.BorderStyle := bsDialog;
LanguageForm.Center;
CancelButton := TNewButton.Create(LanguageForm);
CancelButton.Parent := LanguageForm;
CancelButton.Left := ScaleX(214);
CancelButton.Top := ScaleY(93);
CancelButton.Width := ScaleY(75);
CancelButton.Height := ScaleY(23);
CancelButton.TabOrder := 3;
CancelButton.ModalResult := mrCancel;
CancelButton.Caption := SetupMessage(msgButtonCancel);
OKButton := TNewButton.Create(LanguageForm);
OKButton.Parent := LanguageForm;
OKButton.Left := ScaleX(133);
OKButton.Top := ScaleY(93);
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Caption := SetupMessage(msgButtonOK);
OKButton.Default := True
OKButton.ModalResult := mrOK;
OKButton.TabOrder := 2;
LangCombo := TNewComboBox.Create(LanguageForm);
LangCombo.Parent := LanguageForm;
LangCombo.Left := ScaleX(16);
LangCombo.Top := ScaleY(56);
LangCombo.Width := ScaleX(273);
LangCombo.Height := ScaleY(21);
LangCombo.Style := csDropDownList;
LangCombo.DropDownCount := 16;
LangCombo.TabOrder := 1;
SelectLabel := TNewStaticText.Create(LanguageForm);
SelectLabel.Parent := LanguageForm;
SelectLabel.Left := ScaleX(16);
SelectLabel.Top := ScaleY(8);
SelectLabel.Width := ScaleX(273);
SelectLabel.Height := ScaleY(39);
SelectLabel.AutoSize := False
SelectLabel.Caption := SetupMessage(msgSelectLanguageLabel);
SelectLabel.TabOrder := 0;
SelectLabel.WordWrap := True;
for I := 0 to Languages.Count - 1 do
begin
P := Pos('=', Languages.Strings[I]);
L := Copy(Languages.Strings[I], 0, P - 1);
S := Copy(Languages.Strings[I], P + 1, Length(Languages.Strings[I]) - P);
LangCombo.Items.Add(S);
if L = ActiveLanguage then
LangCombo.ItemIndex := I;
end;
if LanguageForm.ShowModal = mrOK then
begin
{ ... }
end;
end;
function InitializeSetup(): Boolean;
begin
SelectLanguage();
{ ... }
end;
Spanish: first language.
I select English and no change the language of the language selector.
You have the code already. You just need to make some local variables in the SelectLanguage function global, so they can be used in the LangChange function:
var
LanguageForm: TSetupForm;
SelectLabel: TNewStaticText;
CancelButton: TNewButton;
procedure LangChange(Sender : TObject);
begin
case TNewComboBox(Sender).ItemIndex of
0: { English }
begin
SelectLabel.Caption := 'Select the language to use during the installation:';
CancelButton.Caption := 'Cancel';
LanguageForm.Caption := 'Select setup language';
end;
1: { Czech }
begin
SelectLabel.Caption := 'Zvolte jazyk, kter'+#$FD+' se m'+#$E1+' pou'+#$17E+#$ED+'t b'+#$11B+'hem instalace:';
CancelButton.Caption := 'Storno';
LanguageForm.Caption := 'V'+#$FD+'b'+#$11B+'r jazyka pr'+#$16F+'vodce instalac'+#$ED+'';
end;
end;
end;
In the SelectLanguage, remove these the declarations of local variables:
LanguageForm: TSetupForm;
SelectLabel: TNewStaticText;
CancelButton: TNewButton;
And assign the LangChange event handler:
LangCombo.OnChange := #LangChange;

How to remove the bottom panel in inno set up..and replace it with a custom panel

i want to replace the bottom panel where we show Next,Back buttons with a custom panel which includes the installation progress bar..once the installation is completed,then page should automatically redirected to next page.
Below is mockup image,how i want to make this page.
Here is the script including also the main panel header from your previous question as well. Save it into your ..\InnoSetup\Examples\ folder as well as the following images which you need to convert to BMP files since I couldn't find any trusted file sharing site which wouldn't convert the images to PNG or JPG format:
this one convert to BMP and save as Logo.bmp
this one convert to BMP and save as InstallBackground.bmp
Here is the script (you should follow the commented version of this script first):
[Setup]
AppName=ERPBO
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
WizardSmallImageFile=Logo.bmp
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "InstallBackground.bmp"; Flags: dontcopy
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
[Run]
Filename: "{app}\MyProg.chm"; Check: JustBlockTheInstallPage
[Messages]
SetupWindowTitle=Installere - %1
WizardInstalling=Installasjon pågår...
[Code]
function JustBlockTheInstallPage: Boolean;
begin
Result := False;
WizardForm.StatusLabel.Caption := 'Pakker ut filer...';
WizardForm.FilenameLabel.Caption :='C:\dnpr\Crystal reports setup\WindowShoppingNet.msi';
MsgBox('Message just to see the install page :-)', mbInformation, MB_OK);
end;
var
InnerNotebookBounds: TRect;
OuterNotebookBounds: TRect;
InstallBottomPanel: TPanel;
InstallBackground: TBitmapImage;
function Rect(const ALeft, ATop, ARight, ABottom: Integer): TRect;
begin
Result.Left := ALeft;
Result.Top := ATop;
Result.Bottom := ABottom;
Result.Right := ARight;
end;
function GetBoundsRect(AControl: TControl): TRect;
begin
Result.Left := AControl.Left;
Result.Top := AControl.Top;
Result.Right := AControl.Left + AControl.Width;
Result.Bottom := AControl.Top + AControl.Height;
end;
procedure SetBoundsRect(AControl: TControl; const ARect: TRect);
begin
AControl.Left := ARect.Left;
AControl.Top := ARect.Top;
AControl.Width := ARect.Right - ARect.Left
AControl.Height := ARect.Bottom - ARect.Top;
end;
procedure CenterHorizontally(ASource, ATarget: TControl);
begin
ATarget.Left := (ASource.Width - ATarget.Width) div 2;
end;
procedure CenterVertically(ASource, ATarget: TControl);
begin
ATarget.Top := (ASource.Height - ATarget.Height) div 2;
end;
procedure InitializeWizard;
begin
WizardForm.PageDescriptionLabel.Visible := False;
WizardForm.PageNameLabel.Font.Size := 18;
WizardForm.PageNameLabel.Font.Name := 'Comic Sans MS';
WizardForm.PageNameLabel.AutoSize := True;
WizardForm.PageNameLabel.Left := 18;
CenterVertically(WizardForm.MainPanel, WizardForm.PageNameLabel);
WizardForm.WizardSmallBitmapImage.AutoSize := True;
WizardForm.WizardSmallBitmapImage.Left := WizardForm.ClientWidth - WizardForm.WizardSmallBitmapImage.Width - 18;
CenterVertically(WizardForm.MainPanel, WizardForm.WizardSmallBitmapImage);
WizardForm.InstallingPage.Color := clWhite;
InstallBottomPanel := TPanel.Create(WizardForm);
InstallBottomPanel.Parent := WizardForm.InstallingPage;
InstallBottomPanel.BevelOuter := bvNone;
InstallBottomPanel.Align := alBottom;
InstallBottomPanel.Caption := '';
InstallBottomPanel.Color := $00C7CFD3;
InstallBottomPanel.Height := 79;
InstallBottomPanel.ParentBackground := False;
ExtractTemporaryFile('InstallBackground.bmp');
InstallBackground := TBitmapImage.Create(WizardForm);
InstallBackground.Parent := WizardForm.InstallingPage;
InstallBackground.AutoSize := True;
InstallBackground.Bitmap.LoadFromFile(ExpandConstant('{tmp}\InstallBackground.bmp'));
WizardForm.StatusLabel.Parent := InstallBottomPanel;
WizardForm.StatusLabel.Left := 8;
WizardForm.StatusLabel.Top := 8;
WizardForm.FilenameLabel.Parent := InstallBottomPanel;
WizardForm.FilenameLabel.Left := 8;
WizardForm.FilenameLabel.Top := WizardForm.StatusLabel.Top + 16;
WizardForm.ProgressGauge.Parent := InstallBottomPanel;
WizardForm.ProgressGauge.Left := 8;
WizardForm.ProgressGauge.Top := WizardForm.FilenameLabel.Top + 26;
InnerNotebookBounds := GetBoundsRect(WizardForm.InnerNotebook);
OuterNotebookBounds := GetBoundsRect(WizardForm.OuterNotebook);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
begin
SetBoundsRect(WizardForm.OuterNotebook, Rect(OuterNotebookBounds.Left,
OuterNotebookBounds.Top, OuterNotebookBounds.Right, WizardForm.ClientHeight));
SetBoundsRect(WizardForm.InnerNotebook, Rect(OuterNotebookBounds.Left,
WizardForm.Bevel1.Top + WizardForm.Bevel1.Height, OuterNotebookBounds.Right,
WizardForm.ClientHeight));
CenterHorizontally(WizardForm.InstallingPage, InstallBackground);
InstallBackground.Top := InstallBottomPanel.Top - InstallBackground.Height;
WizardForm.ProgressGauge.Width := InstallBottomPanel.Width - 16;
end
else
begin
SetBoundsRect(WizardForm.OuterNotebook, OuterNotebookBounds);
SetBoundsRect(WizardForm.InnerNotebook, InnerNotebookBounds);
end;
end;
And the result how the installation page looks like (and yes, I have used Comic Sans :-)

Windows firewall rule for XP

How to programmatically add an application or port to Windows Firewall on Windows XP?
Try this code extracted from our open source SQlite3UI.pas unit:
function GetXPFirewall(var fwMgr, profile: OleVariant): boolean;
begin
Result := (Win32Platform=VER_PLATFORM_WIN32_NT) and
(Win32MajorVersion>5) or ((Win32MajorVersion=5) and (Win32MinorVersion>0));
if result then // need Windows XP at least
try
fwMgr := CreateOleObject('HNetCfg.FwMgr');
profile := fwMgr.LocalPolicy.CurrentProfile;
except
on E: Exception do
result := false;
end;
end;
const
NET_FW_PROFILE_DOMAIN = 0;
NET_FW_PROFILE_STANDARD = 1;
NET_FW_IP_VERSION_ANY = 2;
NET_FW_IP_PROTOCOL_UDP = 17;
NET_FW_IP_PROTOCOL_TCP = 6;
NET_FW_SCOPE_ALL = 0;
NET_FW_SCOPE_LOCAL_SUBNET = 1;
procedure AddApplicationToXPFirewall(const EntryName, ApplicationPathAndExe: string);
var fwMgr, profile, app: OleVariant;
begin
if GetXPFirewall(fwMgr,profile) then
try
if profile.FirewallEnabled then begin
app := CreateOLEObject('HNetCfg.FwAuthorizedApplication');
try
app.ProcessImageFileName := ApplicationPathAndExe;
app.Name := EntryName;
app.Scope := NET_FW_SCOPE_ALL;
app.IpVersion := NET_FW_IP_VERSION_ANY;
app.Enabled :=true;
profile.AuthorizedApplications.Add(app);
finally
app := varNull;
end;
end;
finally
profile := varNull;
fwMgr := varNull;
end;
end;
procedure AddPortToXPFirewall(const EntryName: string; PortNumber: cardinal);
var fwMgr, profile, port: OleVariant;
begin
if GetXPFirewall(fwMgr,profile) then
try
if profile.FirewallEnabled then begin
port := CreateOLEObject('HNetCfg.FWOpenPort');
port.Name := EntryName;
port.Protocol := NET_FW_IP_PROTOCOL_TCP;
port.Port := PortNumber;
port.Scope := NET_FW_SCOPE_ALL;
port.Enabled := true;
profile.GloballyOpenPorts.Add(port);
end;
finally
port := varNull;
profile := varNull;
fwMgr := varNull;
end;
end;
It will allow you to add an application or a port to the XP firewall.
Should work from Delphi 6 up to XE.
Scripting the Windows Firewall is possible, see Scripting the Windows Firewall
And code examples for example here

Resources