pointer to active document
-
Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.
-
Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.
How many document types are there?
Steve
-
How many document types are there?
Steve
One type only
-
Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.
What is the value of "pDoc" when the crash occurs?
Steve
-
Hi folks, I’ve got a problem getting a pointer to the active document from an MDI. The code below works fine for an SDI, but when I run the binary of the MDI it throws an unhandeled exception error upon trying to access data from the document. When I’m in the editor, however, the intellisense works just fine, ie, when I type ‘pDoc->’ it retrieves the right info from the current document. My question is whether I have to do any additional thing to get the statement below to work for MDIs and what that statement might be. CMtxDoc *pDoc = (CMtxDoc *) ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szHold; pDoc->m_nDim = 2; //exception thrown here Thx, Ralf.
For MDI isn't the active document associated with a view in an MDI child? I'm assuming m_pMainWnd points to a CMDIFrameWnd... CMDIChildWnd *pActiveMDIChild = ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive(); CMDIChildWnd *pActiveMDIChild = ((CMDIFrameWnd*) AfxGetApp()->m_pMainWnd)->MDIGetActive(); if (pActiveMDIChild) { CMtxDoc *pDoc = (CMtxDoc *)pActiveMDIChild->GetActiveDocument(); ... } Mark -- modified at 19:25 Tuesday 16th January, 2007