When you create a custom dialog box in an InstallScript or InstallScript MSI project, you may need to control the visibility of certain controls. An example is radio buttons.

Let’s say you have several radio buttons in a custom dialog box. You do not need all of them to be visible all of the time. Sometimes, you just need one, other times two, and so on. As a result, you want to show the ones you need and hide the ones you don’t.

Here are the basic steps involved.

  1. Call CmdGetHwndDlg() to get the handle to the dialog.
  2. Call GetDlgItem() to get the handle of a radio button control.
  3. Call CtrlSetState() to set the state of a radio button (selected or unselected).
  4. Call _WinSubEnableControl() to enable or disable a radio button.
  5. Call _WinSubShowWindow() to show or hide a radio button.
  6. Call CtrlSetText() to set the text for a radio button.

Check out this code sample:

#define RADIO1   1441
#define RADIO2   1442

HWND     hwndDlg,
                  hwndRadio1,
                  hwndRadio2;

STRING   szDlg;

// set name of custom dialog

szDlg = “DialogName”;

// get handle to custom dialog

hwndDlg = CmdGetHwndDlg(szDlg);

// get handles to radio buttons

hwndRadio1 = GetDlgItem(hwndDlg,RADIO1);
hwndRadio2 = GetDlgItem(hwndDlg,RADIO2);

// set radio button 1 to checked, visible, enabled. finally, set radio button text.

CtrlSetState(szDlg,RADIO1,BUTTON_CHECKED);
_WinSubShowWindow(hwndRadio1,1);
_WinSubEnableControl(hwndDlg,RADIO1,1);
CtrlSetText(szDlg,RADIO1,@IDS_TEXT_STRING1);

// set radio button 2 to unchecked, non-visible, disabled. finally, clear radio button text

CtrlSetState(szDlg,RADIO2,BUTTON_UNCHECKED);
_WinSubShowWindow(hwndRadio2,0);
_WinSubEnableControl(hwndDlg,RADIO2,0);
CtrlSetText(szDlg,RADIO2,@IDS_TEXT_STRING2);

The main point to remember is that you won’t always find InstallScript functions to do what you want. At those times you have to use Windows functions.

 

SQL Server Version Detection in InstallShield

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • NewsVine
  • Reddit
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • Twitter
  • Technorati
  • Live
  • LinkedIn
  • MySpace

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Security Code: