SdOptionsButtons Example

InstallShield 2015 » InstallScript Language Reference

Project: This information applies to the following project types:

InstallScript
InstallScript MSI

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the SdOptionsButtons function.

*

* This script allows the user to select a setup type.  First,

* two lists are created, one for the setup type button icons,

* another for the setup type descriptions.  Then the buttons

* and descriptions are added to the lists.  Next, the dialog

* is presented.  When the user clicks a setup type button, the

* dialog closes and the user's selection is displayed in a

* message box.

*

\*--------------------------------------------------------------*/

 

#include "Ifx.h"

 

function OnBegin()

    STRING  szTitle, szMsg;

    LIST    listButton, listDesc;

    NUMBER  nResult;

begin

 

    // Disable the Back and Next buttons in setup dialogs.

    Disable (BACKBUTTON);

    Disable (NEXTBUTTON);

 

    // Create the lists for buttons and descriptions.

    listButton = ListCreate (STRINGLIST);

    listDesc = ListCreate (STRINGLIST);

 

    if (listButton = LIST_NULL) || (listDesc = LIST_NULL) then

        // Report the error; then terminate.

        MessageBox ("Unable to create lists.", INFORMATION);

        abort;

    endif;

 

    // Add the bitmap buttons to listButton.

    ListAddString (listButton, "@12001;1;255,0,255", AFTER);

    ListAddString (listButton, "@12002;1;255,0,255", AFTER);

    ListAddString (listButton, "@12003;1;255,0,255", AFTER);

    ListAddString (listButton, "@12004;1;255,0,255", AFTER);

 

    // Add the descriptions to listDesc.

    ListAddString (listDesc, "Typical\n" +

                  "Recommended for most computers.", AFTER);

    ListAddString (listDesc, "Portable\n" +

                  "The application will be set up with "  +

                  "options that are useful for portable " +

                  "computers.", AFTER);

    ListAddString (listDesc, "Compact\n" +

                  "To save disk space, none of the " +

                  "optional features will be " +

                  "installed.", AFTER);

    ListAddString (listDesc, "Custom\n" +

                  "For advanced users and system " +

                  "administrators only.  You can " +

                  "customize all available Setup " +

                  "options.", AFTER);

 

    // Display the dialog.

    nResult = SdOptionsButtons (szTitle, szMsg, listButton, listDesc);

 

    // Display a message showing which button was selected.

    switch (nResult)

        case 101:

            MessageBox ("Typical installation selected.", INFORMATION);

        case 102:

            MessageBox ("Portable installation selected.", INFORMATION);

        case 103:

            MessageBox ("Compact installation selected.", INFORMATION);

        case 104:

            MessageBox("Custom installation selected.", INFORMATION);

        default:

            MessageBox ("SdOptionsButtons:\n\n An error occurred.", SEVERE);

    endswitch;

 

    Enable(NEXTBUTTON);

 

    // Destroy the lists.

    ListDestroy (listButton);

    ListDestroy (listDesc);

 

end;