MFC: CDialog from CPropertyPage

491 views Asked by At

I have CPropertySheet which contain multiple CPropertyPage as tabs. In one of the CPropertyPage I have a button and clicking on the button launches a CDialog. I am trying to get the control to CPropertyPage calling GetParent() method inside the CDialog class methods but somehow I don't get the right parent window and when I try to access the members of CPropertypage it throws an Access Violation Exception.

Following is the code I have used:

CDialog *parentDialog = (CDialog *)GetParent(); 

CPropertyPage *parentPage = (CPropertyPage *)parentDialog->GetParent(); 

DResourceStateMgr dSrcStateMgr(parentPage->m_psp.hInstance); 
                                              // throws Access Violation exception.

Same thing used to work in the Visual studio 2008 but when I moved to visual studio 2013 it throws the exception.

0

There are 0 answers