Windows XP Pro, Visual Studio 2008, C++, MFC
Goal: use some checkboxes
Created a Dialog
Created a class for the dialog: C_Control_Logging
Created a checkbox: ID = IDC_CBOX_ENABLE_ALL_LOGGING
Right clicked checkbox and added a variable: m_cbox_logging_enabled
In the constructor is the code:
[code] m_c_box_logging_enabled.SetCheck( BST_CHECKED )[/code}
The result when stepping over this line of code is a popup saying:
Debug Assertion Failed!
The line of code referenced is in afxwin2.inl. I read this as a safety
check point telling me I have a fundamental error in the checkbox code.
I am suspecting that I am not getting the variable associated with the checkbox,
but don't know how to do that.
when I open the properties of the checkbox I don't recognize anything that
indicates that this checkbox is checked or not checked.
How do I get access to this checkbox?
What should I do different?
(BTW: I have been searching, but everything I find is either not C++ or involves creating a checkbox from scratch. I have already created a couple using the Dialog utilities and now just need to find out how to access them.)
Edit: Just so it is said, I can open and close the new dialog box.
Edit again: After reading some more in my text book, I see that my new class does not have an OnInitDialog() function. I supose that means I created the class incorrectly, but I don't see the error of my ways. The book says I can over-ride it, but I have not been able to find that property box yet.
Thank you for your time.
Last edited by bkelly; August 20th, 2012 at 11:34 AM.
OK, I think I understand, but there is no OnInitDialog()(.
After creating what I thought was a class for the dialog box, I have searched the entire solution and the only OnInitDialog() is the one for the main dialog. There is none for the new dialog box.
Given a new dialog box with the ID: IDD_DLG_CONTROL_LOGGING
And within that dialog there is a check box with ID: IDC_CBOX_ENABLE_ALL_LOGGING
And a class for the dialog box named: C_Control_Logging
What do I need to do to gain access to the checkboxes.
My Horton book shows there is a properties sheet that has someting that looks like a method to create an override. But I am unable to find it.
Last edited by bkelly; August 20th, 2012 at 12:24 PM.
Reason: add a phrase
In the class I just declared the method OnInitDialog() and in there I wrote:
CButton *m_ctl_Check = (CButton*) GetDlgItem( IDC_CBOX_ENABLE_ALL_LOGGING );
int status = m_ctlCheck->GetCheck();
m_ctlCheck->SetCheck( BST_CHECKED )
And it does leave the checkbox checked or uncheck per the argument.
I found the line of code for GetDlgItem in another thread. Is that the right way here?
In the Horton book, he indicates I can select the dialog box, right click it, and the popup contains an option to override the OnInitDialog(). I cannot find that dialog. Any instructions on how to find it.
None the less, I do have a method of getting to the checkboxes now.
Thanks for your time.
1.Open the file MyDialog.h.
2.Select the Properties window.
3.Place the cursor on the line that reads class CMyDialog : public CDialog. (The top of the Properties window should show "CMyDialog VCCodeClass" - this is important, because the Properties window is highly context sensitive, and you get different options depending on the location of the cursor in the editor.)
At step 2 I ask: What Properties Window? If I right click the class name itself, there is no Properties selection. If I go to the Visual Studio tool bar and select the button Properties I don't find anything that looks like: class CMyDialog : public CDialog.
Please provide a bit more detail for me.
Class View/right click on the class name. The last item on the pop up menu is properties when I do it. Or you can go to the resource editor and right click in the dialog and get a menu with the properties selection too.