SOLVED: MFC: document-view problem [modified]
-
My application was generared with wizard. It'is SDI. The problem: The document do not automatically attach to the view. The document is creating but the m_pDocument in the view class is always NULL. How can I solve this problem? -- modified at 2:03 Saturday 8th September, 2007
-
My application was generared with wizard. It'is SDI. The problem: The document do not automatically attach to the view. The document is creating but the m_pDocument in the view class is always NULL. How can I solve this problem? -- modified at 2:03 Saturday 8th September, 2007
thats vary simple. say for example, your sdi application is named as example, then your view will be CexampleView and your document class will be CexampleDoc. now your requirement is to get the object of CexampleDoc in CexampleView right?, if it is so, the following is the logic. in CexampleView class(.h file) define a variable like this. CexampleDoc *pDoc; and in constructor or ondraw, pDoc=GetDocument(); now you can access the document class with pDoc.
-
thats vary simple. say for example, your sdi application is named as example, then your view will be CexampleView and your document class will be CexampleDoc. now your requirement is to get the object of CexampleDoc in CexampleView right?, if it is so, the following is the logic. in CexampleView class(.h file) define a variable like this. CexampleDoc *pDoc; and in constructor or ondraw, pDoc=GetDocument(); now you can access the document class with pDoc.
Thanks but I know document/view architecture. I found the problem. IMPLEMENT_DYNCREATE(CSalesmanView, CScrollView) BEGIN_MESSAGE_MAP(CSalesmanView, CScrollView) changed to IMPLEMENT_DYNCREATE(CSalesmanView, CFormView) BEGIN_MESSAGE_MAP(CSalesmanView, CFormView) I was changed the parent of CSalesmanView from CScrollView to CFormView by hand and forgot to change this. SOLVED