Page 1 of 1
Combo box, items
Posted: Wed Nov 10, 2010 9:32 pm
by abhimudgal1
Hi,
How can I populate values of registry in the combo box, after reading from registry if I add item in the dialog editor as $var1$, $var2$, but it shows it as it is not display the value stored in the variable var1 or var2.
thanks in advance
Re: Combo box, items
Posted: Thu Nov 11, 2010 3:19 am
by bokkie
You could try this. Replace REGVALUE1 and REGVALUE2 with the contents you want to display. You then concatenate those values into one uber-variable. In my sample below, MYVALUES contains the list of items I want to put in the combobox each separated by the $NEWLINE$ constant. After the dialog returns, I want the selected value to be returned in my COMBOBOX_SELECTED_VALUE variable. Ok, we have the variables defined.
Set Variable REGVALUE1 to 12345
Set Variable REGVALUE2 to ABCDE
Set Variable MYVALUES to $REGVALUE1$$NEWLINE$$REGVALUE2$
Set Variable COMBOBOX_SELECTED_VALUE to
Now, let's wire this up to the combobox on the dialog. I added a combobox to the licensecheck dialog but you'll use whatever dialog is appropriate to your requirements. Double-click on the dialog to open it in the dialog editor. Add the combobox. Assuming you are wanting to use a non-editable combobox, set the Style property to csDropDownList. Open the Items list and set it's contents to $MYVALUES$. Double-click on the combobox on the dialog and select the Object Behavior tab. Set the Write Values to Variable edit box and enter the variable in your script to receive the selected value. In my example, COMBOBOX_SELECTED_VALUE.
Now select the Object Rules tab. Add a new rule for ComboBox1. On the left-hand side select property ItemIndex equal to -1 and on the right-hand side, select property ItemIndex and set it's new value to 0. What this does is to select the first item in the combobox if one isn't selected. Save your changes to the dialog and close it.
Finally, I added a message box after the dialog is closed in the MSIcode to display the value of $COMBOBOX_SELECTED_VALUE$. So, in my example my combobox contains 12345 and ABCDE and the initial selected item is the first, 12345. Depending on which one I select my message box displays the item I selected.
I'm sure you'll work it out but if you want, I'll post the sample project I used in my example.
Hope this helps.
Edit: I cleaned up my sample project and I've attached it for download. I created it in IA10 but it should open cleanly in version 9 if you don't have 10 installed. Look in the MSIcode and look for the licence check dialog. You can take it from there.
Re: Combo box, items
Posted: Thu Nov 11, 2010 5:24 pm
by mills
Thanks for chiming in, Peter. You really enjoy your dialog editing, don't you?

Re: Combo box, items
Posted: Fri Nov 12, 2010 1:07 am
by abhimudgal1
Thanks a lot bokkie.
There is one issue I am still having, that is if I don't select item from the combo box, and proceed with the default one then message box displays balnk value, so my query is now that How can I get default value in message box, without selecting from the list?
Thanks ...
Re: Combo box, items
Posted: Fri Nov 12, 2010 2:16 am
by bokkie
mills wrote:Thanks for chiming in, Peter. You really enjoy your dialog editing, don't you?

It's been very helpful to me recently. Firstly, I had to re-skin the dialogs to use our company logo and we needed a new dialog as well. Inbound from over the horizon we'll need another, more detailed, dialog which needs some combobox controls and other runtime discovery fields, etc. It was a good chance to relearn what had long laid dormant.
Re: Combo box, items
Posted: Fri Nov 12, 2010 2:43 am
by bokkie
abhimudgal1 wrote:Thanks a lot bokkie.
There is one issue I am still having, that is if I don't select item from the combo box, and proceed with the default one then message box displays balnk value, so my query is now that How can I get default value in message box, without selecting from the list?
Thanks ...
That was exactly something I looked at it yesterday and I could find no solution for so perhaps someone else could perhaps comment. What I did find (slightly off topic) is that you can't set the ItemIndex property to use a variable directly. I tried but I got "invalid property" errors when I ran the installation. What you can do is put an invisible label on the dialog and set its Caption property to receive from the variable that contains the default index position you want to be selected. Then edit the existing rule to say Combobox.ItemIndex = MyLabel.Caption. At runtime it will select the default item for you.
Coming back to your original question, why is it blank if you don't touch the combobox even though it's got the correct value selected? Truth is, I don't know and I can't find a solution that you can try in the dialog. I suspect that it's the act of "touching" the combobox that triggers the internal event handler that then loads the value in the variable. Perhaps Andy can comment on this or propose a solution. I have thought about it but I can't see it. I'll have the chance throughput the day to experiment now and then so if anything comes to mind that works, I'll let you know.
Re: Combo box, items
Posted: Tue Nov 16, 2010 4:57 am
by abhimudgal1
Hello guys,
Thanks a lot for your interest in this problem, I have got a solution for that, following code is for that:
Set Variable COMBOBOX_SELECTED_VALUE to $VARIABLE$
that the solution I am using.
Re: Combo box, items
Posted: Tue Nov 16, 2010 5:50 am
by bokkie
abhimudgal1 wrote:Hello guys,
Thanks a lot for your interest in this problem, I have got a solution for that, following code is for that:
Set Variable COMBOBOX_SELECTED_VALUE to $VARIABLE$
that the solution I am using.
Brilliant! Deceptively easy. The answer was under our noses. I confirm it works.
Edit: I also found this link
http://www.installaware.com/forum/viewt ... f=4&t=2510 detailing the same from way back when.