checkboxes and radio buttons
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:
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement