Public Variable access : New problem
-
Dear Mr Bhavani; Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); CDatastructorView is my view class and m_main is a web-control which i want to use. The compiler responded as : :\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Could you please help me out because i am still pretty at lost. Krugger Krugger
-
Dear Mr Bhavani; Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); CDatastructorView is my view class and m_main is a web-control which i want to use. The compiler responded as : :\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Could you please help me out because i am still pretty at lost. Krugger Krugger
-
Dear Mr Bhavani; Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); CDatastructorView is my view class and m_main is a web-control which i want to use. The compiler responded as : :\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Could you please help me out because i am still pretty at lost. Krugger Krugger
datastruct wrote: Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Due to the way the MFC AppWizard builds files, you will also have to include datastructorDoc.h before you include datastructorView.h datastruct wrote: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); This looks wrong to me.
AfxGetMainWnd
returns a pointer to them_pMainWnd
which in a DocView architecture is usually theCMainFrame
class. I suspect your code needs to be more like thisCMainFrame* pFrame = (CMainFrame*) AfxGetMainWnd();
if(pFrame != NULL)
{
CDatastructorView* pView = (CDatastructorView*) pFrame->GetActiveView();
if(pView != NULL)
{
pView->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0);
}}
-
Dear Mr Bhavani; Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); CDatastructorView is my view class and m_main is a web-control which i want to use. The compiler responded as : :\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Could you please help me out because i am still pretty at lost. Krugger Krugger
The compiler responsed that erros because you did not include header file of CDatastructorView class in lefttooldlg.cpp. In spite of you have done as few guides but errors stilled occurring. It can be that you did not included header correctly. I guess that you have included header file in dialog implementation file, so compiler complained about
GetDocument
member function which declared in such header file. In this case, you should include document header file (I guess it may beDatastructorDoc.h
) before view header file.#include "DocHeader.h" #include "ViewHeader.h"
There are few others way can help you resolve that problem. If you need to include view header file in dialog header file: In header file of dialog, at before dialog declaration, declare:class CDatastructorView;
In dialog implementation file (cpp), include CDatastructorView header file at beforeDatastructorView.h
such below:#include "DatastructorView.h" #include "dialog.h" //Replace by your file name
Good luck -
Dear Mr Bhavani; Thank you for the help that you have given me in accessing a public variable from anywhere within my application. The problem is that the code did not work at all. The compiler strongly complained when i added these code: ((CDatastructorView *) AfxGetMainWnd())->m_main.Navigate"file://c:/datastructor/lectures/recursion_implementation.htm",0,0,0,0); CDatastructorView is my view class and m_main is a web-control which i want to use. The compiler responded as : :\datastructor\lefttooldlg.cpp(1296) : error C2065: 'CDatastructorView' : undeclared identifier C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' C:\datastructor\lefttooldlg.cpp(1296) : error C2059: syntax error : ')' Ps. I have tried whatever Mr Davy and Mr Chen told me but when i include the "datastructorView.h" file within lefttooldlg, i have a few errors telling me that some "doc" stuff are not recognised.... Could you please help me out because i am still pretty at lost. Krugger Krugger