PDA

View Full Version : Preselect RadioButton



blood_on_ice
03-14-2008, 11:09 AM
Hello!

How can I preselect a Radio Button on my Custom Dialog? I know that this:

CtrlSetState("DlgCertificate", RB_CERTIFICATE_ZEITAG, BUTTON_CHECKED);

is the command to set my Radio Button, but I don't want to execute that everytime the User comes to my dialog, only the first time or anywhere before my CustomDialog, but this code doesn't work outside of my dialog-script...here's the code of my dialog:



//===========================================================================
//
// File Name: DlgCertificate.rul
//
// Description: Script-File for the certificate dialog
//
// Comments: Dialog used to get the certificate from the user
//
//===========================================================================
#define NEXT 1
#define BACK 12
#define CANCEL 9
#define DLG_CERTIFICATE_DIALOG 10103
#define RB_CERTIFICATE_ZEITAG 76
#define RB_CERTIFICATE_OTHER 77
#define EDIT_CERTIFICATE_PATH 4
#define EDIT_CERTIFICATE_PASSWORD 55
#define BTN_BROWSE 31

//Variables to store the certificate values
NUMBER nCertificateZeitag;
STRING szCertificatePath;
STRING szCertificatePassword;
NUMBER hwndDlg;
NUMBER hwndItem;

//Declares the function
prototype NUMBER dlgCertificate();
prototype disableComponents();
prototype enableComponents();

//---------------------------------------------------------------------------
// DlgCertificate
//
// Called for the certificate dialog
//---------------------------------------------------------------------------
function NUMBER dlgCertificate()
BOOL bDone;
NUMBER nControl;
NUMBER nReturn;
begin
EzDefineDialog("DlgCertificate",ISUSER,"", DLG_CERTIFICATE_DIALOG);

//Disable the certificate path, if the certificate of Zeit AG is selected
nCertificateZeitag = CtrlGetState("DlgCertificate", RB_CERTIFICATE_ZEITAG);
if( nCertificateZeitag == BUTTON_CHECKED)
then
disableComponents();
endif;

//WaitOnDialog called repeatly, until the user clicks NEXT, BACK OR ABORT
while (!bDone)
nControl = WaitOnDialog("DlgCertificate");
switch (nControl)
case BACK:
//User has clicked BACK
nReturn = BACK;
bDone = TRUE;
case NEXT:
//USER has clicked NEXT
nReturn = NEXT;
bDone = TRUE;
case RB_CERTIFICATE_ZEITAG:
disableComponents();
case RB_CERTIFICATE_OTHER:
enableComponents();
case CANCEL:
//USER has clicked CANCEL
Do (EXIT);
endswitch;
endwhile;

//Stores the configuration typed by the user
nCertificateZeitag = CtrlGetState("DlgCertificate", RB_CERTIFICATE_ZEITAG);
if(nCertificateZeitag == BUTTON_CHECKED)
then
szCertificatePath = INSTALLDIR;
else
CtrlGetText("DlgCertificate", EDIT_CERTIFICATE_PATH, szCertificatePath);
endif;
CtrlGetText("DlgCertificate", EDIT_CERTIFICATE_PASSWORD, szCertificatePassword);
EndDialog("DlgConfiguration");
ReleaseDialog("DlgConfiguration");
return nReturn;
end;

function disableComponents()
begin
hwndDlg = CmdGetHwndDlg("DlgCertificate");
hwndItem = GetDlgItem(hwndDlg, EDIT_CERTIFICATE_PATH);
EnableWindow(hwndItem, FALSE);
hwndItem = GetDlgItem(hwndDlg, BTN_BROWSE);
EnableWindow(hwndItem, FALSE);
end;

function enableComponents()
begin
hwndDlg = CmdGetHwndDlg("DlgCertificate");
hwndItem = GetDlgItem(hwndDlg, EDIT_CERTIFICATE_PATH);
EnableWindow(hwndItem, TRUE);
hwndItem = GetDlgItem(hwndDlg, BTN_BROWSE);
EnableWindow(hwndItem, TRUE);
end;

Thanks!

Kind regards,
Peter

RobertDickau
03-14-2008, 05:48 PM
Perhaps associate the checked state with a variable, and use that in CtrlSetState in the DLG_INIT block of the WaitOnDialog loop instead of hard-coding BUTTON_CHECKED?