Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Functionality to an Existing SQL Dialog

Hi All,

I am trying to add some additional functionality to the already existing SQLServerSelectLogin(Ex) dialog. I'm trying to get the the checkbox to already be checked and the edit box underneath it to have the same value of the database field (and possibly grayed out). I'd also like make it so if I uncheck the box, the text underneath is highlighted/editable.

Is there a way to do this?

Labels (1)
0 Kudos
2 Replies
Flexera beginner

Re: Adding Functionality to an Existing SQL Dialog

There is a bit of manipulation that needs to happen in InstallScript for this kind of change to work. Here are some suggestions.

1) Note the "Control Identifier" for the controls used on your dialog (found in the Installation Designer view for the dialogs) and create InstallScript constants for them in the associated .rul file.


#define DLG_chkbox		19807
#define DLG_TBox 30121

2) Define variables in the ShowDialog function for the dialog for the checkbox, textbox, and the dialog itself.


    HWND 	hDlg;
BOOL bCheckValue;
STRING svServername;

3) In the DLG_INIT code, add statements similar to the following.

	    hDlg = CmdGetHwndDlg(DLG_SQLSELECTLOGIN);
CtrlGetText( DLG_SQLSELECTLOGIN, COMBO_SERVERS, svServername ); //get text from the server list
CtrlSetText( DLG_SQLSELECTLOGIN, DLG_TBox, svServername ); //copy the text to DLG_TBox
CtrlSetState( DLG_SQLSELECTLOGIN, DLG_chkbox, BUTTON_CHECKED ); //check the box for DLG_chkbox
Dlg_ToggleControl( hDlg, DLG_TBox, FALSE ); //make DLG_TBox read-only

4) Add another "case" option for "switch (nId)".


        case DLG_chkbox:
bCheckValue = ( CtrlGetState( DLG_SQLSELECTLOGIN, DLG_chkbox) = BUTTON_CHECKED ); //get the current value of checkbox
Dlg_ToggleControl( hDlg, DLG_TBox, bCheckValue ); // enable/disable the textbox

5) Add a utility function like the following to help with enabling/disabling controls.

prototype Dlg_ToggleControl( byval NUMBER, // hDlg - handle for the dialog
byval NUMBER, // nControlID - ID of the control being toggled
byval BOOL // bState - whether to enable (1) or disable (0) the control
// third argument determines whether to enable (1) or disable (0) the control
function Dlg_ToggleControl( hDlg, nControlID, bState )
number hCtrl;
hCtrl = GetDlgItem( hDlg, nControlID );
EnableWindow( hCtrl, bState );

0 Kudos

Re: Adding Functionality to an Existing SQL Dialog

Thanks so much, that was very helpful!
0 Kudos