BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

CheckBox defaults

I have an Enterprise project with a custom dialog box that contains three CheckBox controls.

Each CheckBox control defines a public property (all uppercase letters). The Value property for each CheckBox control is 1, and the Default Value property is empty.

I am using each CheckBox control to write a value to the registry, in HKLM\[ProductName], to record the state of each CheckBox. The component associated with each registry value has a condition of PROPERTY=1 (where PROPERTY is the public property associated with each CheckBox control).

If the CheckBox control is not selected, then there is no property, and hence the installation does not write the value to the registry. This is not a surprise.

However, I would like to write a value of 1 if the CheckBox is selected, or a 0 (zero) if the check box is not selected.

If I put 0 for Default Value, the CheckBox is selected by default. I would like for the CheckBox not to be selected by default.

Does anyone have any suggestions?

Thanks,

Bill
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

You can do this by creating a controled event for the "Next" button on the dialog in which you have the checkbox.
In the "Dialogs" page, on the dialog you have the checkbox, you select the "Next" button. In the "Published Events" tab you create a new event (using the "SetProperty" event) which looks like this:

Code: Select all

Event_______|_Argument___|_Condition______________
[PROPERTY]  |     0      | AI_INSTALL AND PROPERTY<>1
where PROPERTY is the property associated with the checkbox.

This will set the value of the property "PROPERTY" to 0 if the checkbox is not checked. You can do this for every checkbox you use.

Regards,
cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hi cosmin,

Thanks for your reply.

I would like to accomplish the following:

* The first CheckBox control creates a desktop shortcut. If the CheckBox control is checked, I would like the desktop shortcut to be created. If the CheckBox control is cleared, I would like for the desktop shortcut to be deleted.

* The second and third CheckBox controls define whether Start menu shortcuts should be created. If both of these CheckBox controls are cleared, then the Start menu folder and both shortcuts should be deleted. If only one of these two CheckBox controls are selected, then the Start menu folder should be retained, but the shortcut corresponding to the cleared CheckBox should be deleted.

I appreciate any suggestions on how to accomplish this.

Thanks,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi,

I understand that you want to condition the installation of your shortcuts on the desktop and in the Start Menu. For this you must follow the next steps:
- in the Dialogs page you should Add the dialog named ShortcutDlg
- now select this dialog
- in the Control window (in the right) -> Shortcuts Actions you can configure what options you want.

If you have other questions don't hesitate to ask.

Regards,
Adriana

-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hi Adriana,

The default ShortcutsDlg is not suitable for this package because the package has two features and the appearance of the shortcut CheckBox controls depends on whether neither, both, or only one of the features is selected to be installed. Because of this, I need the CheckBox controls in my custom dialog box to control the creating and deleting of the shortcuts.

I know it is possible to create a registry value as a component, make the shortcut a part of the component, and set a condition on the component. The problem is that if the CheckBox is not selected, the condition evaluates to false.

To illustrate, my package has two main features: Server and Viewer. I have created a custom dialog box and placed three CheckBox controls in my custom dialog box. The public properties associated with these CheckBox controls are DESKTOPSHORTCUT, SERVERSHORTCUT, and VIEWERSHORTCUT. The value for each one of these CheckBox controls is 1 (if one of them is selected, the property will return 1). The default value for each CheckBox control is empty, so the CheckBox controls are not selected by default.

In addition, my package has three registry value components named the same as the public properties (DESKTOPSHORTCUT, SERVERSHORTCUT, and VIEWERSHORTCUT). The corresponding conditional shortcuts are a member of each of these components. Each component has a condition based on the public property (i.e., DESKTOPSHORTCUT=1, SERVERSHORTCUT=1, and VIEWERSHORTCUT=1).

I have defined three searches to set the properties in the case of a Modify install, so if (for example) the DESKTOPSHORTCUT registry value exists, the public property is set to 1 and the corresponding CheckBox control in my custom dialog is thus selected.

The problem is that if I run a Modify install and deselect (for example) the DESKTOPSHORTCUT CheckBox, the property is deleted, so the condition for the component that contains the DESKTOPSHORTCUT registry value and shortcut evaluates to false, and the shortcut is never deleted, even though I deselected it in the dialog box.

What I would like to happen: If I uncheck the DESKTOPSHORTCUT CheckBox in the custom dialog, the corresponding component (and shortcut) should be deleted.

If you need more details, or if you can suggest a better way of accomplishing my goals, please let me know.

Thanks,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi,
I know it is possible to create a registry value as a component, make the shortcut a part of the component, and set a condition on the component. The problem is that if the CheckBox is not selected, the condition evaluates to false.
I don't understand what is the problem here, please give me more details if you consider it's still a problem.
The problem is that if I run a Modify install and deselect (for example) the DESKTOPSHORTCUT CheckBox, the property is deleted, so the condition for the component that contains the DESKTOPSHORTCUT registry value and shortcut evaluates to false, and the shortcut is never deleted, even though I deselected it in the dialog box.

What I would like to happen: If I uncheck the DESKTOPSHORTCUT CheckBox in the custom dialog, the corresponding component (and shortcut) should be deleted.
That happens because the component's feature is not reinstalled and components are not transitive.


You have several options:
- Display your custom dialog only on first time install.
- Display it also on Repair (you will have to make those components transitive).
- Display it also on Modify additionally you have to force reinstallation of component's feature (so it is better to move those components in a different feature).


If you choose the display only on Repair there are the steps you should follow:
- From the Organization Page, the components must be set as transitive.
- You must display your dialog on First Time Install and on Repair (MaintenanceTypeDlg->Repair->Control->PublishEvents the NewDialog from VerifyRepair became your dialog and Condition = 1) - The "Next" button on your dialog should have the next conditions:

Code: Select all

 Event      | Argument          | Condition
NewDialog    VerifyRepairDlg     1 AND InstallMode="Repair"
NewDialog    FolderDlg           AI_INSTALL 

If you want to display that dialog also on Modify let us know and we will give you more information.



Regards,
Adriana



-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
Last edited by Adriana on Mon Sep 10, 2007 12:50 pm, edited 1 time in total.
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

BillStewart wrote:I know it is possible to create a registry value as a component, make the shortcut a part of the component, and set a condition on the component. The problem is that if the CheckBox is not selected, the condition evaluates to false.
Adriana wrote:I don't understand what is the problem here, please give me more details if you consider it's still a problem.
My point was that the condition evaluates to false because the CheckBox is not checked, and thus the shortcut does not get deleted.
Adriana wrote:That happens because the component's feature is not reinstalled and components are not transitive.
Can you please explain this statement further? How does one reinstall a feature that is already installed?
Adriana wrote:You have several options:
- Display your custom dialog only on first time install.
- Display it also on Repair (you will have to make those components transitive).
- Display it also on Modify additionally you have to force reinstallation of component's feature (so it is better to move those components in a different feature).
The first option is not optimal, because then you must make a good choice on the first installation. After that, you cannot modify and add the shortcuts later.

The second option is not optimal, because if the shortcut components are installed, they will automatically be reinstalled, so I don't see an advantage.

The third option is best, but please explain why the shortcuts have to be put in a separate feature.
Adriana wrote:If you want to display that dialog also on Modify let us know and we will give you more information.
Yes, please explain further.

Regards,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi,

Windows Installer can't install or uninstall the components individually. It always install or uninstall the entire feature. That happens also when a component is missing and a repair is automatically triggered.
It also reevaluates the value of the component condition upon a reinstall only for transitive components.

You must:
- put the components as transitive
- move them in a separated feature
- reinstall that feature every time ( or only every time the checkboxes are changing ) - that is the reason for this feature containing only those small components.


In First Time Install you have added your dialog that contains your shortcut's checkboxes that have each one its property set on 1 and by default no value.

On the Next button of your NewDialog you should have the next Publish Events:

Code: Select all

NewDialog       FolderDlg       AI_INSTAL - which is already set 
NewDialog       VerifyRepairDlg        (InstallMode="Repair")
NewDialog       VerifyReadyDlg         (InstallMode="Change"), 
the last two have to be added.

On the Install button of your VerifyReadyDlg you should have the next Published Events:

Code: Select all

ReinstallMode        ecmus          (InstallMode="Change")
Reinstall            Feature        (InstallMode="Change"),
where Feature is the name of the recently created feature.

In the Maintenance > MaintenanceTypeDlg > CostumizeDlg you should add your dialog too by changing the Next button's NewDialog Published Event from VerifyReadyDlg to NewDialog.
Maybe you will have some issues with Back buttons in dialogs as: VerifyReadyDlg, VerifyRepairDlg and NewDialog.You can solve it by adding properly conditioned Published Events to those Back buttons.

I hope that is useful.

Regards,
Adriana



-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
Last edited by Adriana on Tue Sep 11, 2007 8:06 am, edited 4 times in total.
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hi Adriana,

Let me see if I understand your instructions.

I have moved the registry values (and their associated shortcuts) to a separate feature called Shortcuts. The feature's Display setting is set to Not Displayed, and the feature's Install Level is set to 1. The feature has no conditions.

Each component in the new feature has a condition for the associated CheckBox control in my custom dialog. For example, the component that creates the desktop shortcut has a condition of DESKTOPSHORTCUT=1, and DESKTOPSHORTCUT is the public property name in my custom dialog. The components are all marked as Transitive.

I have added two control events to the Install button on the VerifyReadyDlg, as follows:

Code: Select all

Event            Argument   Condition
[ReinstallMode]  cemus      AI_INSTALL And (InstallMode=Change)
[Reinstall]      Shortcuts  AI_INSTALL And (InstallMode=Change)
I still have this problem: Each component has a condition that refers to a CheckBox control. If the CheckBox is not checked, then the condition evaluates to False and the associated shortcut is not deleted. What I would like to happen, if InstallMode=Change, is that if a CheckBox gets unchecked, the shortcut should get deleted.

Let me know if you need more details.

Thanks,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi,

You must use the correct conditions:

Code: Select all

Event              Argument           Condition
ReinstallMode      ecmus              1 And (InstallMode=Change)
Reinstall          Shortcuts          1 And (InstallMode=Change)
If it doesn't work please send the AIP file to support at advancedinstaller dot com in order to investigate this issue.

Regards,
Adriana

-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
Last edited by Adriana on Mon Sep 10, 2007 12:54 pm, edited 3 times in total.
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hello Adriana,

The Install button on the VerifyReadyDlg now has the following Published Events:

Code: Select all

Event            Argument        Condition
==========================================
EndDialog        Return          OutOfDiskSpace <> 1
SpawnDialog      OutOfRbDiskDlg  OutOfDiskSpace = 1 AND...*
EndDialog        Return          OutOfDiskSpace = 1 AND...*
EnableRollback   False           OutOfDiskSpace = 1 AND...*
[ReinstallMode]  cemus           1 And (InstallMode=Change)
SpawnDialog      OutOfDiskDlg    (OutOfDiskSpace = 1 AN...*
[Reinstall]      Shortcuts       1 And (InstallMode=Change)
* (I did not change these conditions from the defaults)
The feature called Shortcuts contains the registry values and associated shortcuts. Each component in the Shortcuts feature has a condition related to the CheckBox control on my custom dialog box.

However, the package's behavior is still not what I would like it to be. I will mail it to you for comments.

Thanks,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi Bill,

The problem is that you don't use the Reinstall and ReinstallMode Control Events but rather two SetProperty Control Events (you have used square brackets around ReinstallMode and Reinstall). The correct events are the following:

Code: Select all

Event              Argument               Condition
ReinstallMode      ecmus              1 And (InstallMode=Change)
Reinstall          Shortcuts          1 And (InstallMode=Change)
Please let me know if this solves the problem.

Best regards,
Adriana

-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hi Adriana,

That does not solve the problem, because the components in the Shortcuts feature have conditions tied to the custom dialog box. If the box is not checked, the condition evaluates to false, and thus the components are not installed (or removed).

Thanks,

Bill
Adriana
Posts: 28
Joined: Tue Aug 14, 2007 9:32 am
Location: Craiova
Contact: Website

Hi Bill,

I have checked your project and found the following errors:
- in the Search Page one of the search properties is typed incorrectly ("SERVERSHORTUCT" instead of "SERVERSHORTCUT")
- in the Dialogs page the Conditions for the Reinstall and ReinstallMode Control Events on the "Install" button of the VerifyReadyDlg are incorrect (you should have used quotes around "Change"):

Code: Select all

1 And (InstallMode="Change")
instead of

Code: Select all

1 And (InstallMode=Change)
- the other mistake is the one mentioned in my previous post: you should have used the Reinstall and ReinstallMode Control Events not SetProperty Control Events.

We have sent the modified project to your email address.

Let us know if you encounter any other problems!

Best regards,
Adriana

-----------------------
Adriana Simion
Advanced Installer Team
http://www.advancedinstaller.com/
BillStewart
Posts: 34
Joined: Sat Jul 28, 2007 1:48 am

Hi Adriana,

Success! Thanks for your help!

Bill

Return to “Common Problems”