Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Check Box

Posted on 1998-11-24
2
Medium Priority
?
182 Views
Last Modified: 2010-08-05
Hi... I have a dialog based MFC application with a button on it to go to a property sheet. On the property sheet, I have a check box. The constructor of the property sheet sets the checkbox to FALSE. This means that whenever I open the property sheet, the checkbox is always off, even though I may change it to on, exit the property sheet and then go back into the property sheet. You may have guessed my question now... how do I get the checkbox to remember its previous state? I have added code in the constructor with a variable to change when the state of the check box changes so I have something like this in the constructor
int check;
BOOL checkbox;
if (check == 1)
checkbox = TRUE;
This code works great. However when I try to edit the code and go into the class wizard, I get a parsing error that it was not expecting a "==" and that it was expecting a "=", and all hell breaks loose. So, how do I recall a state of the checkbox without upsetting class wizard? Thanx


0
Comment
Question by:rose337
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1178548
The code you have posted looks fine and should not cause a parsing error unless you placed it in the wrong place in your program.  however, I don't see how that code can help you at all.  
If you need to "remember" the state of the checkbox, you will need to store its state in a global varaible or in a static variable that is a member of the class.
0
 
LVL 3

Accepted Solution

by:
Norbert earned 150 total points
ID: 1178549
Class wizzard generates something like that:
CSomeClassDlg::CSomeClassDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CSomeClassDlg::IDD, pParent)
{
      //{{AFX_DATA_INIT(CSomeClassDlg)
      m_SomeMember = _T("");
      //}}AFX_DATA_INIT
}
Inside the //{{AFX_DATA_INIT block you sholul normaly
not change anything
You have 2 solutions:
1)
Don't care  about initialisation inside //{{AFX_DATA_INIT
make your own after //}}AFX_DATA_INIT
2)
Make the initialisation inside OnInitDialog where the
complete dialog is available (including Window size and handle)

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question