marketware
Level 6

How to access custom control value

I have added a custom Checkbox Control to the SQLServerSelect dialog and would like to access its value in my installscript. Can someone please help me to know what function, etc. I can use to access its value?

I've tried the following, but I'm not getting it right (or its the wrong function)

NUMBER nState;
STRING szIfEncrypt;

//Control Identifier
#define ENCRYPTCHECKBOX 17818

Dlg_SQLServerSelect:

szMsg = "";
szServer = MW_SERVERNAME;

SQLRTInitialize2();

nResult = SQLServerSelect( szMsg, szServer );

if (nResult = BACK) goto Dlg_SdRegisterUser;
if (nResult = IDCANCEL) then
// The user clicked the window's close button.
Do (EXIT);
endif;

if (nResult = CANCEL) then
Do (EXIT);
endif;

nState = CtrlGetState("DialogId_10110", ENCRYPTCHECKBOX);

if (nState = BUTTON_CHECKED) then
MessageBox( "button checked", SEVERE );
szIfEncrypt = "true";

endif;
Labels (1)
0 Kudos
7 Replies
kill136
Level 3

I also meet this problem.lucky , I finished !give me your e-mail
0 Kudos
marketware
Level 6

The question I asked and its solution should be a simple one. Can you please share it with us?
0 Kudos
skolte
Level 7

Not sure if this will work but you might want to give it a try, add this after your call to SQLServerSelect.

 
szDialogName = "SQLServerSelect";
nResult = CtrlGetState ( szDialogName, ID_OPTION1 );
if(nResult = BUTTON_CHECKED) then
MessageBox("Custom checkbox checked", 0);
endif;
0 Kudos
marketware
Level 6

That doesn't seem to be the correct way to refer to that dialog. :confused:

Does anyone know if we are on the right path, but just not referring to the SQLServerSelect Dialog correctly? Or is there another way to get the value of the checkbox I've added to that dialog?

The (name) of the checkbox is CheckBox1, its Control Identifier is 17818.
The Dialog name seems to be DialogId_10110 and it's Resourse Identifier is 10110.

Thanks in advance for any ideas...

bob
0 Kudos
skolte
Level 7

1. Is there a SQL connection added under SQL Scripts? If not, please add one even though you won't use it as SQL Functions are used in conjunction with SQL Connection.

2. My code below is probably incorrect because when you click Next dialog has already been dismissed so it returns nothing. What I mean by that is CtrlGetState needs to be called before your dialog is dismissed; for SQLServerSelect, make a copy of SQLServerSelect source code, refer to script\isrt\src directory of your InstallShield dir, add this code in your project and add the CtrlGetState call to that copy perhaps under SD_PBUT_CONTINUE.

Also, I think before calling SQLServerSelect, there needs to be SQLRTInitialize2(); similar to OnSQLLogin(). Let's worry about it if the first two steps above don't work.
0 Kudos
ch_eng
Level 7

Bob,

Don't know if this helps, but every time I customize the SQL dialog (ex: adding checkboxes and other controls), I have needed to add this sort of code

nState = CtrlGetState("DialogId_10110", ENCRYPTCHECKBOX);


inside the dialog's script file. I generally use SQLServerSelectLoginEx2 but the process should be the same for SLQServerSelect:

1. Copy this file to your project directory and rename it (ex: customSQLServerSelect.rul)
C:\Program Files\InstallShield\2010\Script\Isrt\src\SQLServerSelect.rul

2. Change the function name of "SQLServerSelect" to something else (ex: ShowDialog_SQLServerSelect)

3. Use this code inside the new file to access the checkbox value (assuming you have defined ENCRYPTCHECKBOX and nState in this file):
nState = CtrlGetState(DLG_SQLSELECT, ENCRYPTCHECKBOX); 


4. In your Setup.rul file, change the SQL function call (which is currently "nResult = SQLServerSelect( szMsg, szServer );" to whatever you changed the function name to (in step 2. above).

5. In your Setup.rul file, add an #include filename.rul line for the file you copied to your project directory (in step 1. above).

Hopefully that gets you most of the way there.

HTH
0 Kudos
skolte
Level 7

Bob,

This morning I had some time so quickly put together a working sample for you.

It is in . I built it with 2012 Pro.
0 Kudos