I have created a custom form to display an options page, which I am trying to position in the centre of wherever the WizardForm is at the time an Options button is clicked. I have tried the following code, but it is not positioning it as described.
[Code]
var
OptionsWindowForm: TForm;
{ Show the Options window }
procedure ShowOptionsWindow;
begin
OptionsWindowForm := TForm.Create(nil);
with OptionsWindowForm do
begin
Parent := WizardForm;
BorderStyle := bsDialog;
Position := poMainFormCenter;
ClientWidth := ScaleX(400);
ClientHeight := ScaleY(140);
Caption := '{#AppName} Options';
ShowModal;
end;
end;
I also tried poOwnerFormCenter for the Position property and by setting Left and Top properties, which seem to be ignored.
Is there a way to position this as described?
It indeed does not seem to work as expected.
Though this seems to work:
OptionsWindowForm := TForm.Create(WizardForm); { Make WizardForm the owner }
with OptionsWindowForm do
begin
Position := poOwnerFormCenter; { Center on the owner }
{ ... }
ShowModal;
end;
Related
The image I am not allowed to resize the image I am using for the MainPanel. This is causing issues, as it is covering an input query page I have created. How do I make sure the input query page with "grow" with the size dimensions set by the MainPanel image?
procedure InitializeWizard;
begin
{ Extract the banner so we can use it with the input page. }
BannerImage := TBitmapImage.Create(WizardForm);
BannerImage.Bitmap.LoadFromFile('C:\temp\tempbanner.bmp');
{ Create the Bitmap Banner img to show on the Main Panel. }
BannerImage.Parent := WizardForm.MainPanel;
WizardForm.MainPanel.Width := SPLASH_SCREEN_WIDTH;
WizardForm.MainPanel.Height := BANNER_HEIGHT;
BannerImage.Width := WizardForm.MainPanel.Width;
BannerImage.Height := WizardForm.MainPanel.Height;
{ BannerImage.Anchors := [akLeft, akTop, akRight, akBottom]; }
BannerImage.Stretch := False;
BannerImage.AutoSize := False;
WizardForm.WizardSmallBitmapImage.Visible := False;
WizardForm.PageDescriptionLabel.Visible := False;
WizardForm.PageNameLabel.Visible := False;
{ Create the input page }
ReportingServerPage := CreateInputQueryPage(wpWelcome,
'Title', 'What is your XXX?',
'Please enter your Server URL, then click Next.'+#13#10+#13#10+'If you proceed without entering a URL, you can update it in the %AppData%\xxxxxxxx\xxxx\xxxxx\xxxx_launcher.properties file at a later stage.');
ReportingServerPageId := ReportingServerPage.ID;
{ Add items (False means it's not a password edit) }
ReportingServerPage.Add('&Reporting Server URL:', False);
end;
You have to increase window height and move the window contents (Bevel1 and InnerNotebook) down.
Note that the bottom aligned controls (the bottom buttons) move automatically with the window height increase (assuming you use the latest version of Inno Setup).
[Files]
Source: "banner.bmp"; Flags: dontcopy
[Code]
var
ReportingServerPage: TInputQueryWizardPage;
procedure InitializeWizard;
var
BannerImage: TBitmapImage;
Delta: Integer;
begin
BannerImage := TBitmapImage.Create(WizardForm);
ExtractTemporaryFile('banner.bmp');
BannerImage.AutoSize := True;
BannerImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\banner.bmp'));
BannerImage.Parent := WizardForm.InnerPage;
BannerImage.Left := 0;
BannerImage.Top := 0;
Delta := BannerImage.Height - WizardForm.Bevel1.Top;
WizardForm.Height := WizardForm.Height + Delta;
WizardForm.Bevel1.Top := WizardForm.Bevel1.Top + Delta;
WizardForm.InnerNotebook.Top := WizardForm.InnerNotebook.Top + Delta;
WizardForm.InnerNotebook.Height := WizardForm.InnerNotebook.Height - Delta;
WizardForm.MainPanel.Visible := False;
{ Create the input page }
ReportingServerPage := CreateInputQueryPage(wpWelcome,
'Title', 'What is your XXX?',
'Please enter your Server URL, then click Next.'+#13#10+#13#10+
'If you proceed without entering a URL, you can update it in the ' +
'%AppData%\xxxxxxxx\xxxx\xxxxx\xxxx_launcher.properties file at a later stage.');
{ Add items (False means it's not a password edit) }
ReportingServerPage.Add('&Reporting Server URL:', False);
end;
Note that the code does not cater for image/window width. It assumes the image width fits the window width.
I have added new checkboxes to my inno setup tasks page but i dont know how to make them work with the tasks, i want them to work with the [Tasks] zone in the script.
[Tasks]
Name: "Newcheckboox1"; Description: "Newcheckbox1"; MinVersion: 0.0,5.0
Name: "Newcheckboox2"; Description: "Newcheckbox2"; MinVersion: 0.0,5.0
other tasks checkboxes here.........
Here an image:
Here the code generated when the checkboxes are added:
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
NewGroupBox1: TNewGroupBox;
NewCheckBox1: TNewCheckBox;
NewCheckBox2: TNewCheckBox;
NewCheckBox3: TNewCheckBox;
NewGroupBox2: TNewGroupBox;
NewCheckBox4: TNewCheckBox;
NewCheckBox5: TNewCheckBox;
NewGroupBox3: TNewGroupBox;
NewCheckBox6: TNewCheckBox;
NewCheckBox7: TNewCheckBox;
NewCheckBox8: TNewCheckBox;
procedure RedesignWizardForm;
begin
with WizardForm.SelectTasksLabel do
begin
Visible := False;
Left := ScaleX(392);
end;
{ NewGroupBox1 }
NewGroupBox1 := TNewGroupBox.Create(WizardForm);
with NewGroupBox1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(0);
Top := ScaleY(0);
Width := ScaleX(145);
Height := ScaleY(238);
Caption := 'NewGroupBox1';
end;
{ NewCheckBox1 }
NewCheckBox1 := TNewCheckBox.Create(WizardForm);
with NewCheckBox1 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(16);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox1';
end;
{ NewCheckBox2 }
NewCheckBox2 := TNewCheckBox.Create(WizardForm);
with NewCheckBox2 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(40);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox2';
end;
{ NewCheckBox3 }
NewCheckBox3 := TNewCheckBox.Create(WizardForm);
with NewCheckBox3 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(64);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox3';
end;
NewCheckBox1.TabOrder := 0;
NewCheckBox2.TabOrder := 1;
NewCheckBox3.TabOrder := 2;
{ NewGroupBox2 }
NewGroupBox2 := TNewGroupBox.Create(WizardForm);
with NewGroupBox2 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(152);
Top := ScaleY(0);
Width := ScaleX(265);
Height := ScaleY(97);
Caption := 'NewGroupBox2';
end;
{ NewCheckBox4 }
NewCheckBox4 := TNewCheckBox.Create(WizardForm);
with NewCheckBox4 do
begin
Parent := NewGroupBox2;
Left := ScaleX(8);
Top := ScaleY(16);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox4';
end;
{ NewCheckBox5 }
NewCheckBox5 := TNewCheckBox.Create(WizardForm);
with NewCheckBox5 do
begin
Parent := NewGroupBox2;
Left := ScaleX(8);
Top := ScaleY(40);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox5';
end;
NewCheckBox4.TabOrder := 0;
NewCheckBox5.TabOrder := 1;
{ NewGroupBox3 }
NewGroupBox3 := TNewGroupBox.Create(WizardForm);
with NewGroupBox3 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(152);
Top := ScaleY(96);
Width := ScaleX(265);
Height := ScaleY(142);
Caption := 'NewGroupBox3';
end;
{ NewCheckBox6 }
NewCheckBox6 := TNewCheckBox.Create(WizardForm);
with NewCheckBox6 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(24);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox6';
end;
{ NewCheckBox7 }
NewCheckBox7 := TNewCheckBox.Create(WizardForm);
with NewCheckBox7 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(48);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox7';
end;
{ NewCheckBox8 }
NewCheckBox8 := TNewCheckBox.Create(WizardForm);
with NewCheckBox8 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(72);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox8';
end;
NewCheckBox6.TabOrder := 0;
NewCheckBox7.TabOrder := 1;
NewCheckBox8.TabOrder := 2;
NewGroupBox1.TabOrder := 2;
NewGroupBox2.TabOrder := 3;
NewGroupBox3.TabOrder := 4;
{ ReservationBegin }
// This part is for you. Add your specialized code here.
{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!
procedure InitializeWizard();
begin
RedesignWizardForm;
end;
You cannot "make them work with Tasks". That does not make sense. The only purpose of Tasks is to automatically create the checkboxes on the "Select Additional Tasks" page. As you create the checkboxes programmatically, there's nothing that Tasks will give you on top of that.
If you want to use your custom checkboxes as Tasks, use Check parameter, instead of Tasks.
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Check: IsCustomTask1Selected
[Code]
var
NewCheckBox1: TNewCheckBox;
function IsCustomTask1Selected: Boolean;
begin
Result := NewCheckBox1.Checked;
end;
For a complete solution, see How to split tasklist at tasks page of Inno Setup into multiple columns?
It works with the latest version of proper Inno Setup, with no need for an obsolete custom build of Inno Setup of doubtful origin.
Side notes:
I'd recommend you to use TNewCheckListBox, instead of TNewGroupBox with individual checkboxes.
5.5.1 is very old version that suffers many security issues.
Add a method for OnClickCheck event,
procedure InitializeWizard;
begin
WizardForm.TasksList.OnClickCheck := #TasksListClickCheck
end;
Then implement TasksListClickCheck method,
procedure TasksListClickCheck(Sender: TObject);
begin
/** Do whatever you want here **/
end;
I have a custom page SelectPage that I am creating two custom check boxes on. The relevant parts of the code from InitializeWizard procedure are below:
//Define the Restart Services Checkbox
RestartServicesCheckBox := TNewCheckBox.Create(WizardForm);
with RestartServicesCheckBox do
begin
Parent := SelectPage.Surface;
Caption := 'Restart Services';
Left := OptionsLabel.Left;
Top := OptionsLabel.Top + ScaleY(20);
Checked := True;
end;
//Define the Restart Server Checkbox
RestartServerCheckBox := TNewCheckBox.Create(WizardForm);
with RestartServerCheckBox do
begin
Parent := SelectPage.Surface;
Caption := 'Restart Server';
Left := OptionsLabel.Left;
Top := RestartServicesCheckBox.Top + ScaleY(22);
Checked := False
end;
This works and I get the check boxes that I want and they perform the actions that I assign to them. What I am struggling to work out is how to assign a dependency between the two, so that if one is checked, the other is automatically unchecked. However, I do not want a radio buttons type dependency, as both checkboxes might need to be unchecked. I was looking at trying to intercept the OnClick event something like this:
var
DefaultOnClick: TNotifyEvent;
procedure InitializeWizard();
begin
//Store the original OnClick event procedure and assign custom procedure
DefaultOnClick := WizardForm.TCheckBox.OnClick;
WizardForm.TCheckBox.OnClick := #OnClick;
end;
//Uncheck and Restart Services if Restart Server is checked and vice versa
procedure UpdateOptions();
begin
with RestartServicesCheckBox do
begin
if RestartServicesCheckBox.Checked then
begin
Checked := False;
end;
end;
with RestartServerCheckBox do
begin
if RestartServerCheckBox.Checked then
begin
Checked := False;
end;
end;
end;
//Update the options check boxes if the states change and restore the original event handler procedures
procedure OnClick(Sender: TObject);
begin
DefaultOnClick(Sender);
UpdateOptions;
end;
However, I do not know what the full event name is that I need to intercept. It clearly isn't WizardForm.TCheckBox.OnClick anyway. What would this event name be and will this method work? Alternatively, is there a simpler way to do this?
It is the TCheckBox.OnClick event that you need to use.
var
RestartServicesCheckBox: TNewCheckBox;
RestartServerCheckBox: TNewCheckBox;
procedure RestartServicesCheckBoxClick(Sender: TObject);
begin
if RestartServicesCheckBox.Checked then
RestartServerCheckBox.Checked := False;
end;
procedure RestartServerCheckBoxClick(Sender: TObject);
begin
if RestartServerCheckBox.Checked then
RestartServicesCheckBox.Checked := False;
end;
procedure InitializeWizard();
begin
// Define the Restart Services Checkbox
RestartServicesCheckBox := TNewCheckBox.Create(WizardForm);
with RestartServicesCheckBox do
begin
...
Checked := True;
OnClick := #RestartServicesCheckBoxClick;
end;
// Define the Restart Server Checkbox
RestartServerCheckBox := TNewCheckBox.Create(WizardForm);
with RestartServerCheckBox do
begin
...
Checked := False;
OnClick := #RestartServerCheckBoxClick;
end;
end;
Though I think that three radio buttons might be better:
Do not restart
Restart service only
Restart server
My Inno setup installer consist only on 2 custom pages.
in the first custom page show show "Abort" button and "Agree and Install" button
in the second custom page I want to replace the "Abort" button with "Decline" button,
just to change the caption of the button !
I dont know how to adress the page ID of the first and the second page so i cant make it happen.
I have seen how to create custom pages and add them to the wizard in the InitializeWizard procedure.
My problem is that when I create a custom page the default page for install location selection does not appear any more.
What options do I have to keep the default page(install location selection) and also add a my new custom page?
Code:
--------- here are my pages - -----------
procedure CreateTheWizardPages;
var
Page: TWizardPage;
Title: TNewStaticText;
Desc: TRichEditViewer;
CB_border: TPanel;
HPCB: TCheckBox;
HP_Lable:TRichEditViewer;
DSCB: TCheckBox;
DS_Lable:TRichEditViewer;
Footer: TRichEditViewer;
LinkTerms, LinkPP: TNewStaticText;
DeclineButton: TNewButton;
checkx: integer;
begin
Page := CreateCustomPage(
wpWelcome,
ExpandConstant('{cm:MainOfferPageCaption}'),
ExpandConstant('{cm:MainOfferPageDescription}'));
Page.Surface.Notebook.SetBounds(10, 70, ScaleX(WizardForm.Width), ScaleY(500));
{ Title }
Title := TNewStaticText.Create(Page);
Title.Parent := Page.Surface;
Title.Left := ScaleX(0);
Title.Top := ScaleY(0);
Title.Width := ScaleX(200);
Title.Height := ScaleY(30);
Title.Color := -16777186;
Title.Font.Name := 'Verdana';
Title.Font.Style := [fsBold];
Title.Caption := 'Wise Convert app';
Title.Font.size := 12;
Title.TabOrder := 1;
Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox and others');
{ Title }
Title := TNewStaticText.Create(Page);
Title.Parent := Page.Surface;
Title.Left := ScaleX(0);
Title.Top := ScaleY(0);
Title.Width := ScaleX(200);
Title.Height := ScaleY(30);
Title.Color := -16777186;
Title.Font.Name := 'Verdana';
Title.Font.Style := [fsBold];
Title.Caption := 'Wise Convert app';
Title.Font.size := 18;
Title.TabOrder := 1;
end;
------- here i change the buttons caption ----------
procedure CreateAgreeButton(ParentForm: TSetupForm; nextButton: TNewButton);
var
AgreeButton: TNewButton;
begin
WizardForm.NextButton.Caption := '&Agree and Install';
end;
procedure CreateCancelButton(ParentForm: TSetupForm; CancelButton: TNewButton);
begin
WizardForm.CancelButton.Caption := '&Abort';
WizardForm.backButton.Visible := false;
end;
This is the code section from inno setup.My intention is to make two Checkbox where at a time one is being selected.
But this code return error when first checkbox is clicked.
[code]
procedure CheckBoxOnClick(Sender: TObject);
var
Box2,CheckBox: TNewCheckBox;
begin
if CheckBox.Checked then ///error:"Could not call proc" [sud it be global if then how to or what to change?]
BEGIN
CheckBox.State := cbUnchecked;
Box2.State := cbChecked;
END else
BEGIN
CheckBox.State := cbChecked;
Box2.State := cbUnchecked;
END;
end;
procedure Box2OnClick(Sender: TObject);
var
Box2,CheckBox: TNewCheckBox;
begin
if Box2.Checked then ///error:same
BEGIN
CheckBox.State := cbChecked;
Box2.State := cbUnchecked;
END else
BEGIN
CheckBox.State := cbUnchecked;
Box2.State := cbChecked;
END;
end;
procedure CreateTheWizardPages;
var
Page: TWizardPage;
Box2,CheckBox: TNewCheckBox;
begin
{ TButton and others }
Page := CreateCustomPage(wpWelcome, '', '');
CheckBox := TNewCheckBox.Create(Page);
CheckBox.Top :=ScaleY(8)+ScaleX(50);
CheckBox.Width := Page.SurfaceWidth;
CheckBox.Height := ScaleY(17);
CheckBox.Caption := 'Do this';
CheckBox.Checked := True;
CheckBox.OnClick := #CheckBoxOnClick;
CheckBox.Parent := Page.Surface;
Box2 := TNewCheckBox.Create(Page);
Box2.Top :=ScaleY(8)+ScaleX(70);
Box2.Width := Page.SurfaceWidth;
Box2.Height := ScaleY(17);
Box2.Caption := 'No,Thanks.';
Box2.Checked := False;
Box2.OnClick := #Box2OnClick;
Box2.Parent := Page.Surface;
end;
procedure InitializeWizard();
//var
begin
{ Custom wizard pages }
CreateTheWizardPages;
end;
Please tell me where to change..
The cause of your error is that your are referencing CheckBox which is defined locally in that method. At this point CheckBox has not been created. Which means your calling CheckBox.Checked when CheckBox is undefined (most likely NIL)
Each declaration of CheckBox represents a new variable and does not reference the other variables with the same name. This is due to scoping rules.
One option to solve your problem is to remove the local declarations of Box2, and CheckBox in each method and declare them globally.