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

Enabling dialog controls from checkbox

This is a pretty basic thing, but I'm having trouble figuring out how to do it. In a dialog I have a checkbox, and if it's checked I want a few edit text fields below to be enabled, otherwise disabled. I've been looking at the event and subscription behavior tables for the controls, but I'm not sure what to do. Thanks.
Labels (1)
0 Kudos
(2) Replies
Level 6

I created a very similar method that allows that to be possible. Below is the code that is used to achieve the functionality.

Pass in the following parameters:

DialogName -- Name of the Dialog
ControlID -- ID of the controls you wish to manipulate
IsVisible -- true if you wish to enable the control; otherwise, false.

You can use CtrlGetState to get the state of the button and if it is equal to BUTTON_CHECKED then enable the controls.

if(CtrlGetState(DialogName, CheckBoxControl) = BUTTON_CHECKED) then
EnableItem(DialogName,..., true);
EnableItem(DialogName,..., false);

/// Sets a value that indicates whether the windows control is
/// enabled.

function EnableItem(sDialogName, nControlID, IsVisible)
HWND hDialog, hInstance;
hDialog = CmdGetHwndDlg(sDialogName);
hInstance = GetDlgItem(hDialog, nControlID);

EnableWindow(hInstance, IsVisible);
0 Kudos
Level 7

what type of project?
0 Kudos