InstallShield Tips and Techniques

March 8, 2011

Setting up a Combo Box Dialog

Filed under: Reference Materials — shieldmaster @ 11:02 pm

Setting up the Windows Installer ComboBox can be hard to understand, but once mastered, you can use some flexible methods to create the list entries.

Here, I show a basic interior dialog “ISI_ComboBox” created with a Combo Box dropped onto it. The MSI Property associated with the Combo Box is “ISI_COMBOBOX”

To supply some fixed entries for the Combo Box, I switch to the Direct Editor, and select the ComboBox table.

I create three entries for the same MSI Property “ISI_COMBOBOX”, ensure the Order for display is in the sequence that I want and supply unique values. Now to specify the default value, I switch to the Property Manager and specify the default value for the MSI Property “ISI_COMBOBOX”

Here is the finished dialog – upon initial display the default instructor “Mike” is displayed:

And when the user selects the drop down, the other instructors are displayed:

But what if the entries in the Combo Box are dynamic – say you want to supply the user with a list of Client ODBC entries that should be linked to your Client installation.

Obviously this list is very dynamic , and will change for each user. Here is some InstallScript code that allows you to take as input a list “ODBC_CLIENTS” and inject these entries into the MSI table before the dialogs are displayed:

//**   Open view into ComboBox table

//*****************************************************************

MsiDatabaseOpenView(ISMSI_HANDLE,”SELECT * FROM `ComboBox` WHERE `Property`=’ODBC_CLIENTS'”, hViewlist);

   

MsiViewExecute(hViewlist, NULL);  

r = 0;                               

// Get the first string in the list.

nResult = ListGetFirstString (sKeys, szODBClients);

MsiSetProperty (ISMSI_HANDLE, “ODBC_CLIENTS”, szJODBClients);

    // Loop while list items continue to be retrieved.

    while (nResult != END_OF_LIST)

                szODBClientsTemp=szODBClients;

        StrReplace ( szODBClientsTemp, “_”, “”, 0 );

        StrReplace ( szODBClientsTemp, “.”, “”, 0 );

        StrToNum (szODBClientsNum, szODBClientsTemp);       

                if szODBClientsNum > 14200 then

                                r = r + 1;

                hRecordlist = MsiCreateRecord(4);                                                

                MsiRecordSetString(hRecordlist, 1, “ODBC_CLIENTS”);

                MsiRecordSetInteger(hRecordlist, 2, r);

                MsiRecordSetString(hRecordlist, 3, szODBClients);

                MsiRecordSetString(hRecordlist, 4, “”);

                // can only temporarily modify running .msi database

                MsiViewModify(hViewlist, MSIMODIFY_INSERT_TEMPORARY, hRecordlist);

                // Get the next string in the list.   

        endif;

        nResult = ListGetNextString (sKeys, szODBClients);   

                                                 

    endwhile;    

Note: It is up to you to create and populate the String list “ODBC_CLIENTS”, then select a string to populate the MSI Property ISI_COMBOBOX for the default value.

Here is additional reference from Robert Dickau here:

Hope this helps!

ShieldMaster

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: