How to set default value for checkbox control - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

How to set default value for checkbox control

Hi,

I am new to AI, great product and i have read the help file extensively - i like to read technical materials - developer background. I find it very light on technical "howto". Yes, the FAQ "How to" helps but doesn't go far enough. I am coming from using wise soultion InstallMaster therefore Windows installer seem very rigid but it seem that this is going to be the only game in towm therefore I have to learn and use it for my product. I have tried other UI implementation for MS Windows installer and i have find AI the most friendly but it needs to develop the help file and documentation further to become the best to help users to go beyond the simple installations like my product and this would reduce a lot of traffic on your forum.

Question: How do I set my checkbox control to "x" or tick prior to showing my custom dialog. I know i have to setup an initialization event but how? My checkbox control's property name is "CHECKBOXPB1"
checkbox.gif
checkbox.gif (14.66 KiB) Viewed 12538 times
- see my edit controlevent dialog but didn't give me my desired result.

I will appreciate any help.

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to set default value for checkbox control

Hello and welcome to Advanced Installer forums,

This is even easier than that. Simply fill in the Default Value field from the checkbox's Properties pane to the right.

Let me know if it helped.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Hi Gabriel,

Thanks for your reply. I have tried that option and it worked, i.e. the installer showed the checkbox checked but my custom action script (.vbs) used to set which feature to installed accroding to the checkbox settings didn't pick up the default value setting. However, when I ran the installer again uncheck the already checked box then checked value was registered by my custom action script and that it why i want to perform the checking in an initialization event perhaps that would work for me. The other option I have is force the user to check what they want then i trade away my user friendlyness of my installer. I hope you could help.

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to set default value for checkbox control

Hello,

Did you set your script to run as an Init Event? It is best you set it to run as a Published event on the "Next" button so that it sets the feature after the user is done making changes.

Let me know if this helped.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Hi Gabriel,

The referenced VB script is a published event for my next button. And this is why it picked up the checkbox state when i had to uncheck then recheck the control.

You can't help me with an example for setting a checkbox control using an initialization event, surely, you should have a fews.

Thanks

Moshud
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Hi Gabriel,

I have figured out, how to set an Init event to checkbox by default myself but i am back to square 1, my custom action script didn't pick up the current state of my checkbox control - help - how do I fix this new issue.

This is wierd, if i physically interact with the checkbox control my CA script picks up their current state but if done through the interface no joy.

For the benefit of others who wants to know how I solved my own problem:
Click on checkbox control then click on Initialization Events tab (Init Events).
Now click on "New" button. The name of my checkbox control is "CHECKBOXPB1".
Under name field, select "set property" from list, [PropertyName] would be placed in the name field.
Change to your property name, in my case I changed it to [CHECKBOXPB1] and lastly enter "1" in the Argument field.

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

Re: How to set default value for checkbox control

Hi,
my custom action script didn't pick up the current state of my checkbox control
Can you please give me more details about this? How are you retrieving the checkbox state? Please note that the correct approach is to get the checkbox property value.
This is wierd, if i physically interact with the checkbox control my CA script picks up their current state but if done through the interface no joy.
Interacting with the control shouldn't matter. The property value is always there, so most likely the problem is in your custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Interacting with the control shouldn't matter. The property value is always there, so most likely the problem is in your custom action.
The same CA script worked if i left the checkbox control unchecked and at installation run time i manually checked the checkbox. In this scenario, the CA script would pick up the correct state of the checkbox. However, if i used the default value to check the checkbox control and don't click on the control at installation time the state of the checkbox control returned "uncheck" in the CA script. My script is based on your example script on checkbox and radio button controls. Find below my CA script. I have tried "AirefreshDlg" but didn't make any difference. It is very easy to recreate perhaps a bug gone unnoticed all this while.

Code: Select all

' Set contants for the INSTALLSTATE_ABSENT and INSTALLSTATE_LOCAL feature states
Const msiInstallStateAbsent = 2
Const msiInstallStateLocal  = 3

'setting AiRefreshDlg refreshes the controls on a dialog when Enhanced UI is enabled
Session.Property("AiRefreshDlg") = cstr(1)


' Set the install state of the feature with the identifier "FeatureP2" [European Pallets]
If Session.Property("CHECKBOXPB1") = "CheckBox" Then 
   Session.FeatureRequestState("FeatureP2") = msiInstallStateLocal
Else
   Session.FeatureRequestState("FeatureP2") = msiInstallStateAbsent
End If

' Set the install state of the feature with the identifier "FeatureP1" [US Pallets]
If Session.Property("CHECKBOXPB2")="CheckBox" Then
   Session.FeatureRequestState("FeatureP1") = msiInstallStateLocal
Else
   Session.FeatureRequestState("FeatureP1") = msiInstallStateAbsent
End If
Thanks

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

Re: How to set default value for checkbox control

Hi Moshud,

I tested your script and it works correctly when using a default value. What default values were set for your checkboxes? Did you use CheckBox (the value you are checking in the script)?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Hi Cosmin,

Since any value for default value would set the check on, I set the my default value to "1" but the value property is set to "CheckBox". Do i need to make the value and defalut value properties the same to make this happen? Well, i will test this and get back to you tomorrow.

I must say, only you experts would know this, these knowledge needs to be pushed out to your user guide !

Thanks

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

Re: How to set default value for checkbox control

Hi Moshud,
I set the my default value to "1" but the value property is set to "CheckBox".
Your script is checking if the property is set to "CheckBox", so the default value should also be set to "CheckBox". You need to match the default value with what you are checking in your script. If the property is set to "1", it will never be seen as set to "CheckBox".

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How to set default value for checkbox control

Hi Cosmin,

All works perfectly. By matching the "default value" with the "value" property my CA script now picks up the pre-set state of my checkbox control. Setting the control through Init events works too. Thanks very much.

Cosmin, you and your team would be hear from me alot since my existing installer (Wise solutions InstallMaster) did a lot of custom things outside just copying files onto the target PCs.

Talk to you soon.

Thanks

Moshud

Return to “Common Problems”