cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sandeep_anantha
Level 4

unable to read selected value from radiobuttongroup

😞 Hi all,

I am using Installshield 2009 and created custom dialog box. It has a radioboxgroup control which inturn has 2 radio controls to capture type of installation.( Primary or Secondary). Please find the script below. I could not get the selected Value through CtrlGetState. This always returns -1. I found that I need to associate a property to RadiobuttonGruop. I dont know how to do it. Please assist in retrieving the radiobuttongroups selected value.

Thanks
Sandeep

PS: My Project is of type Installscrcipt basic MSI Project.


#define BUTTON_NEXT 1
#define BUTTON_BACK 12
#define RD_PRIMARY 73
#define RD_SECONDARY 74
#define RDG_IGATYPE 52

prototype NUMBER TypeOfServer( );
function NUMBER TypeOfServer( )

STRING szDialogName, szDLLName, szDialog;
NUMBER nDialog, nResult, nCmdValue,nReturn,nPrimaryvalue,nSecondaryvalue;
BOOL bDone, bResult;

begin

// Specify a name to identify the custom dialog in this installation.
szDialogName = "TypeOfServer";
// Define the dialog. Pass a null string in the second parameter
// to get the dialog from _isuser.dll or _isres.dll. Pass a null
// string in the third parameter because the dialog is identified
// by its ID in the fourth parameter.

nResult = EzDefineDialog (szDialogName, ISUSER, szDialogName, 0);
if (nResult < 0) then
// Report an error; then terminate.
MessageBox ("Error in defining dialog", SEVERE);
abort;
endif;
// Initialize the indicator used to control the while loop.
bDone = FALSE;
// Loop until done.
repeat
// Display the dialog and return the next dialog event.
nCmdValue = WaitOnDialog(szDialogName);
// Respond to the event.
switch (nCmdValue)
case DLG_CLOSE:
// The user clicked the window's Close button.
Do (EXIT);
case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
case DLG_INIT: ;
// No initialization is required for this example.
case BUTTON_BACK:
// The user clicked the Cancel button.
nReturn = BACK;
bDone=TRUE;
case BUTTON_NEXT:
nPrimaryvalue=CtrlGetState(szDialogName, 73);
nSecondaryvalue=CtrlGetState(szDialogName, 74);
bDone=TRUE;
bResult = FALSE;



// Replace szOrigValue with szReplaceValue.

bDone = TRUE;
endswitch;
until bDone;
// Close the dialog.
EndDialog (szDialogName);
// Free the dialog from memory.
ReleaseDialog (szDialogName);
return nReturn;
end;
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

PS: My Project is of type Installscrcipt basic MSI Project.


Sorry, is it "InstallScript MSI" or "Basic MSI"? If InstallScript, I'm not sure you need to associate a property with the radio button group. If Basic MSI, you do need a property, and would not use EzDefineDialog, WaitOnDialog, etc.
0 Kudos
TheTraveler
Level 8

Hello

The first thing I would look at is the Control Identifier. If they don't match, you will not get the correct state.

I also noticed that you were missing the "SdInit" function call.

The code below was taken from your example and I modified it to conform it a little. Instead of using constants, I have been using a memory structure to hold that information.

Let me know what you think about the changes I made and see if it works for you.

[CODE]#ifndef _IS_STANDARD_BUTTONS
#define _IS_STANDARD_BUTTONS

#define IS_DLG_btnBack 12
#define IS_DLG_btnCancel 9
#define IS_DLG_btnNext 1
#define IS_DLG_txtTitle 50
#define IS_DLG_txtSubTitle 51
#define IS_DLG_dlgClose 2

#endif // _IS_STANDARD_BUTTONS

#define RD_PRIMARY 73
#define RD_SECONDARY 74
#define RDG_IGATYPE 52

typedef Custom_Dialog
begin
string strName[50];

///////////////////////////////////////////////////////////////////////////
// C o n t r o l s I D s //
///////////////////////////////////////////////////////////////////////////
number ctrl_rbPrimary;
number ctrl_rbSecondary;
end;

prototype Custom_Dialog_Create();
prototype Custom_Dialog_Free();
prototype Custom_Dialog_ShowModal(BYVAL STRING, // txtTitle
BYVAL STRING, // txtSubTitle
BYVAL BOOL // bPrimary
);

Custom_Dialog dlgMyDialog;

///////////////////////////////////////////////////////////////////////////////
// C u s t o m _ D i a l o g _ C r e a t e //
///////////////////////////////////////////////////////////////////////////////
function Custom_Dialog_Create()
begin
dlgMyDialog.strName = "TypeOfServer"

dlgMyDialog.ctrl_rbPrimary = 73; // Controler Identifier found in the properties of the control
dlgMyDialog.ctrl_rbSecondary = 74; // Controler Identifier found in the properties of the control
end;

///////////////////////////////////////////////////////////////////////////////
// C u s t o m _ D i a l o g _ F r e e //
///////////////////////////////////////////////////////////////////////////////
function Custom_Dialog_Free()
begin
// No global dialog resource to free up...
end;

///////////////////////////////////////////////////////////////////////////////
// C u s t o m _ D i a l o g _ S h o w M o d a l //
///////////////////////////////////////////////////////////////////////////////
function Custom_Dialog_ShowModal(txtTitle, txtSubTitle, bPrimary)
string szDlg;
bool bDone;
number nId;
HWND hDlg;
begin
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
Custom_Dialog_Create();
szDlg = dlgMyDialog.strName;

///////////////////////////////////////////////////////////////////////////
// Check the global variable to see if InstallScript
// has already been initialized for custom dialogs.
// Initialize the environment if not already initialized.
///////////////////////////////////////////////////////////////////////////
if(!bSdInit) then
SdInit();
endif;

///////////////////////////////////////////////////////////////////////////
// Define the dialog using the string name that is
// used to identify it in the resource file.
///////////////////////////////////////////////////////////////////////////
if(EzDefineDialog(szDlg, ISUSER, szDlg, 0) < 0) then
MessageBox("Error defining dialog box", INFORMATION);
abort;
endif;

///////////////////////////////////////////////////////////////////////////
// Loop in the dialog until the user takes action
// to close the dialog by clicking on a button.
///////////////////////////////////////////////////////////////////////////
bDone = FALSE;
while(!bDone)
///////////////////////////////////////////////////////////////////////
// Display the dialog and retrieve messages
// based on the users interaction with the dialog.
///////////////////////////////////////////////////////////////////////
nId = WaitOnDialog(szDlg);

// Respond to the event.
switch (nId)
case DLG_INIT:
///////////////////////////////////////////////////////////////
// Some dialog functions require the Winodws Handle... //
///////////////////////////////////////////////////////////////
hDlg = CmdGetHwndDlg(szDlg);

///////////////////////////////////////////////////////////////
// Setting the title of the Dialog... //
///////////////////////////////////////////////////////////////
CtrlSetText(szDlg, IS_DLG_txtTitle, txtTitle );
CtrlSetText(szDlg, IS_DLG_txtSubTitle, txtSubTitle);

///////////////////////////////////////////////////////////////
// Setting the state of the Radio buttons... //
///////////////////////////////////////////////////////////////
if bPrimary then
CtrlSetState(szDlg, dlgMyDialog.ctrl_rbPrimary, BUTTON_CHECKED );
CtrlSetState(szDlg, dlgMyDialog.ctrl_rbSecondary, BUTTON_UNCHECKED);
else
CtrlSetState(szDlg, dlgMyDialog.ctrl_rbPrimary, BUTTON_UNCHECKED);
CtrlSetState(szDlg, dlgMyDialog.ctrl_rbSecondary, BUTTON_CHECKED );
endif;

///////////////////////////////////////////////////////////////
// Next button on click event //
///////////////////////////////////////////////////////////////
case IS_DLG_btnNext:
bDone = TRUE;
bPrimary = CtrlGetState(szDlg, ctrl_rbPrimary.ctrl_rbPrimary) = BUTTON_CHECKED;

///////////////////////////////////////////////////////////////
// The code in this case statement responds to
// the end user clicking the Cancel button or the
// Close button.
///////////////////////////////////////////////////////////////
case DLG_CLOSE:
Do(EXIT);

///////////////////////////////////////////////////////////////
// Cancel button on click Event...
///////////////////////////////////////////////////////////////
case IS_DLG_btnCancel:
Do(EXIT);

///////////////////////////////////////////////////////////////
// Close Event...
///////////////////////////////////////////////////////////////
case IS_DLG_dlgClose:
Do(EXIT);

///////////////////////////////////////////////////////////////
// The code in this case statement responds to
// the end user clicking the Back button.
///////////////////////////////////////////////////////////////
case IS_DLG_btnBack:
bDone = TRUE;

case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
endswitch;
endwhile;

///////////////////////////////////////////////////////////////////////////
// Close the dialog.
///////////////////////////////////////////////////////////////////////////
EndDialog(szDlg);

///////////////////////////////////////////////////////////////////////////
// Release memory used by the dialog.
///////////////////////////////////////////////////////////////////////////
ReleaseDialog(szDlg);

///////////////////////////////////////////////////////////////////////////
// Return the control ID of
// the control that was clicked.
///////////////////////////////////////////////////////////////////////////
return nId;
end;
[/CODE]
0 Kudos