VC++ 6.0 中 theApp 对象怎么用...?.?/..//..//????

来源:百度知道 编辑:UC知道 时间:2024/06/20 11:08:41
在 VC++ 8.0 中 theApp 可以直接用,但在 VC++ 6.0 中却用不了了,怎么回事呢.?./??

theApp2007-12-11 21:46theApp不是全局对象吗,为什么我用它时提示
error C2065: 'theApp' : undeclared identifier
怎样才能访问他呢
------------
AfxGetApp()
---------
在你要访问的地方的 .cpp 文件中加入

extern CYourApp theApp;
-------------------
在要访问的文件中加入
extern CXXXApp theApp;
----------
得到指向app的指针
如 ((CYourApp *)AfxGetApp())->你的成员变量

在别的类中直接使用theApp要 extern 下

--------------
类型转换啊
(CMyApp*)AfxGetApp()
---------------
eG:
HWND hList = ::GetDlgItem(((CEVENTApp *)AfxGetApp())->m_pMainWnd->m_hWnd, IDC_LISTRESULT);
-----------

利用函数AfxGetApp()获取全局变量指针theApp

1,vc++6.0中,在本文件是可以使用的,要是想在别的文件中用加上

extern TYPE theApp;

加上extern TYPE theApp;