If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

creating and accessing a checkbox

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.

Re: creating and accessing a checkbox

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 01:24 PM.
Reason: add a phrase

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.

Re: creating and accessing a checkbox

Hello,
In that link I find:

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.

Re: creating and accessing a checkbox

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.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.