Pointer/address to CFormView
-
Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have:
CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; }
But*pView
is null and I get an error. How can I make*pView
attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student) -
Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have:
CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; }
But*pView
is null and I get an error. How can I make*pView
attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student) -
Im in the CMainFrame class. I have a CFormView with many screens. In CMainFrame, how can I get a pointer to my class so that I can access variables in the CFormView. I have:
CListCtrl* CMainFrame::GetListCtrl1098() { CMyFormView *pView = NULL; CListCtrl* pmyListCtrl = &pView->m_list_1098; return pmyListCtrl; }
But*pView
is null and I get an error. How can I make*pView
attain access to its class and hence variables? Please, any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)Your code:
CMyFormView *pView = NULL;
CListCtrl* pmyListCtrl = &pView->m_list_1098;
will not work. You have set
pView
to NULL and then tried to use it as a pointer to a list control object. You may need to review the relationship between your classes.It's time for a new signature.
-
You could try
pView = GetActiveView();
You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
The problem is, GetActiveView() returns something other than the CMyFormView which has the listctrl that I want to attain. Even if I try:
void CMainFrame::GetListCtrl() { CMyFormView *pView; CListCtrl* pmyListCtrl = NULL; if (pView) { AfxMessageBox("view active"); pmyListCtrl = pView->m_list_ctrl; int total = pmyListCtrl->GetItemCount(); CString s; s.Format("total = %i", total); AfxMessageBox(s); } }
it doesnt work. Please any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student) -
The problem is, GetActiveView() returns something other than the CMyFormView which has the listctrl that I want to attain. Even if I try:
void CMainFrame::GetListCtrl() { CMyFormView *pView; CListCtrl* pmyListCtrl = NULL; if (pView) { AfxMessageBox("view active"); pmyListCtrl = pView->m_list_ctrl; int total = pmyListCtrl->GetItemCount(); CString s; s.Format("total = %i", total); AfxMessageBox(s); } }
it doesnt work. Please any response any one can give me will be greatly appreciated. Sincerely, Danielle Brina (an overworked graduate student)