Some possibilities have already been given to you. If you use classwizard, you can assign a member variable of type BOOL to a check box. Doing this will fill in all the right code for you. As I remember (I don't touch CW with a barge pole) you can even assign an initial value of 1 (TRUE) to it. If not, all you have to do is find the line in the constructor which initialises the check variable and change it to say = 1; or = TRUE; depending on taste. If you want to do it the hard way, then the following code will help. Is assume you have a check box of value IDC_CHECK1, and you are making a dialog class called CMyDlg. In the header:
class CMyDlg : public CDialog
{
public:
CMyDlg (....);
....
BOOL m_bCheckValue;
....
protected:
void DoDataExchange (CDataExchange *pDX);
BOOL OnInitDialog ();
....
};
In the implementation file (eg. mydlg.cpp)
CMyDlg (...) : CDialog (....)
{
....
m_bCheckValue = TRUE;
....
}
BOOL CMyDlg::OnInitDialog ()
{
....
BOOL bReturn = CDialog::OnInitDialog ();
....
return bReturn;
}
void CMyDlg::DoDataExchange (CDataExchange *pDX)
{
CDialog::DoDataExchange (pDX); // Nothing actually happens here, but its good practice.
....
DDX_Check (pDX, IDC_CHECK1, m_bCheckValue);
....
}
I put in the OnInitDialog just to remind you you need to call the base member to ensure DoDataExchange gets called. By putting the DDX_Check in, rather than just checking the box in OnInitDialog, we make sure that the value is retrieved when you press OK, so you can find out whether the user cleared the check box or not. Iain.