标签:
代码截图:
1 void CClass_twoDlg::OnTest() 2 { 3 // TODO: Add your control notification handler code here 4 // 获取 CClass_twoApp类的指针 5 CClass_twoApp* pApp = (CClass_twoApp*)AfxGetApp(); 6 // 创建指针变量 获取到的指针 让他 指向 成员 m_pMainWnd 7 CWnd* pMainWnd =pApp->m_pMainWnd; 8 //创建CString变量 赋值 空 9 CString strText =_T(""); 10 // 格式化文本 11 strText.Format("pMainWnd=Ox%X\nthis=Ox%X\n",pMainWnd,this); 12 //显示文本 13 AfxMessageBox(strText); 14 15 }
获取 应用程序主窗口的指针。
调用函数:
AfxGetApp();无参数 返回 应用程序 指针
调用 成员变量
m_pMainWnd;
因为 pApp是一个指针 他可以 访问 派生类的 父类。。 详情 请学习C++。
Visual C++实效编程 280 第一章 窗口 1.2获得应用程序主窗口的指针
标签:
原文地址:http://www.cnblogs.com/summergull/p/5900996.html