Solved

Check Box

Posted on 1998-11-24
2
170 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TTimer no longer functioning 7 85
Load and store *.pnm image file 1 77
Arduino EDI - Programming language 3 80
passing data from one form to another form in c++ 27 75
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now