Advertisement

checkboxes and radio buttons

Started by July 25, 2003 10:19 AM
3 comments, last by didalabu2 21 years, 7 months ago
I wanted to add some configuration options to my demo. I was wondering if anyone knows how to check the state of a checkbox or radio button from a dialog box WITHOUT USING MFC. Thanks
Assuming your dialog box is a derivative of CDialog:

void CYourClass::YourFunction(void){  CYourDialogClass Dlg;  if( Dlg.DoModal() == IDOK ) // Replace IDOK with your equivalent affirmative response  {    if( Dlg.IsCheckBoxMarked() )      // Do something    if( Dlg.IsRadioButtonMarked() )      // Do something  }}


Even if your dialog box wasn''t a derivative of CDialog, you could still set some variables that would signify a box being marked or button being pressed. Just access those variables after the dialog box has closed, but before the object goes out of scope.

---
K-1 Productions: Come visit us here.
---K-1 Productions: Come visit us here.
Advertisement
int box_statebox_state=IsDlgButtonChecked(hwnd,ID_NAME_OF_CHECKBOX);if(box_state == BST_CHECKED){   //Do something}else{   //Do something else} 


Hope that helps.
I can look into that, but it seems like too much work to create a whole dialog class.

for example, if I have a text box i can grab the text in it by using:

char text[256];
GetDlgItemText(hwnd, IDC_SOMETEXTBOX, text, 256);

or

int x;
x = GetDlgItemInt(hwnd, IDC_SOMETEXTBOX, NULL, true);


so i figured it is as simple as a single function to get the state of a checkbox or radio button.

Is there a simpler way.
thanks Xiachunyi

you replied as i was typing my last post, so i didnt see it at first.

that should work.

This topic is closed to new replies.

Advertisement