Solved

Check Box

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

776 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