Solved

Check Box

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

707 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

15 Experts available now in Live!

Get 1:1 Help Now