Help on obtaining a pointer to my CDocument derived class
-
I need help obtaining a pointer to my CDocument class in a class that I have derived from CTabPageSSL. The TabPageSSL control can be found on this site and it essentially allows you to used child dialog box resources as a TabPage. My problem is this. I need to be able to take text entered on one tab and place it onto a diffent tab. My view class is CFormView which I have then placed a tab control on the main view. On this control is where I have placed two tabs using the TabCtrlSSL. I can respond to the ON_EN_CHANGE of the individual tabs but I can not figure out how to pass this information on to the CDocument class. In all the examples that I have read and seen, they use a function called GetDocument() but this is only available inside my View class. I have attempted to create a function similar to it inside my derived class for my tab pages, but have had no luck. Can anyone help me obtain a pointer to my CDocument or is there an easier way to pass information from between my child dialog boxes? Thanks in advance for any help you can provide. -Eric
-
I need help obtaining a pointer to my CDocument class in a class that I have derived from CTabPageSSL. The TabPageSSL control can be found on this site and it essentially allows you to used child dialog box resources as a TabPage. My problem is this. I need to be able to take text entered on one tab and place it onto a diffent tab. My view class is CFormView which I have then placed a tab control on the main view. On this control is where I have placed two tabs using the TabCtrlSSL. I can respond to the ON_EN_CHANGE of the individual tabs but I can not figure out how to pass this information on to the CDocument class. In all the examples that I have read and seen, they use a function called GetDocument() but this is only available inside my View class. I have attempted to create a function similar to it inside my derived class for my tab pages, but have had no luck. Can anyone help me obtain a pointer to my CDocument or is there an easier way to pass information from between my child dialog boxes? Thanks in advance for any help you can provide. -Eric
you can use the following function to get your document from any place in your app (just replace 'CMyDocument')...
CMyDocument* DangerousGetDocument()
{
CWinApp* pApp = ::AfxGetApp();
POSITION p = pApp->GetFirstDocTemplatePosition();
ASSERT(p);CDocTemplate* pTmp = pApp->GetNextDocTemplate(p);
p = pTmp->GetFirstDocPosition();
ASSERT(p);CDocument* pDoc = pTmp->GetNextDoc(p);
ASSERT(pDoc);return reinterpret_cast<CMyDocument*>(pDoc);
}..have fun... jk :cool:
-
you can use the following function to get your document from any place in your app (just replace 'CMyDocument')...
CMyDocument* DangerousGetDocument()
{
CWinApp* pApp = ::AfxGetApp();
POSITION p = pApp->GetFirstDocTemplatePosition();
ASSERT(p);CDocTemplate* pTmp = pApp->GetNextDocTemplate(p);
p = pTmp->GetFirstDocPosition();
ASSERT(p);CDocument* pDoc = pTmp->GetNextDoc(p);
ASSERT(pDoc);return reinterpret_cast<CMyDocument*>(pDoc);
}..have fun... jk :cool:
jk, Thanks for the help. I stumbled onto what appears to be an answer late last night. I am attempting the following... CFrameWnd *pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CFormView *pView = (CFormView *)pFrame->GetActiveView(); CMyDocument *pDoc = (CMyDocument *)pView->GetDocument(); Thanks again though for the help, -Eric