Hai All
I am developing MFC based SDI application in VC++ derived from CFormView class.In my dialog I have a checkbox. When this check box is clicked or not I want to get the state of this check box in main class say CDemoView.cpp and use that particular state for some calculations in another class say OServer.cpp which is a C++ class. I tried using SetCheck(), GetCheck() functions and I am failing.How can I get the state of checkbox in my other class??
I used the following code to get pointer to my view class from OServer.cpp:
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
pView = (CDemoView *) pChild->GetActiveView();
In my view class I used the following code to check the state of checkbox
void CDemoView::OnBnClickedEnableLog()
{
checked = ::IsDlgButtonChecked(m_hWnd, IDC_ENABLE_LOG);
if( checked == 1)
IsSetLog = true;
else
IsSetLog = false;
UpdateData(FALSE);
}
Here the variables are declared in following manner
UINT checked;
bool IsSetLog;
I am using the state of this checked variable in OServer.cpp as follows.
if(pView->checked)
{
if(pView->IsSetLog > 0)
LogResponse(strData);
}
While debugging I am getting pView->checked value as the same value as in view class. But in OServer.cpp class the function LogResponse is not working for both cases i.e control doesnot gets into this if block
What is probably the problem? If I am wrong anywhere please help me with code portions..
Thanks..