有时提示功能并不能及时生效,而需要你重新编译后才行.
所以提示框里没有出现那个函数并不能说明不能调用它...通过框架取视的方法因SDI或MDI略有不同,这个问题在以前的贴子中多次出现过.对于MDI程序如下:
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
// Get the active MDI child window.
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();
// or CMDIChildWnd *pChild = pFrame->MDIGetActive();// Get the active view attached to the active MDI child
// window.
CMyView *pView = (CMyView *) pChild->GetActiveView();如果是SDI程序直接使用GetActiveView即可.
解决方案 »
- vs2008 mfc 添加最近文件和最近工程
- BCB6.0与VC++2005,哪个更适合入门?
- 单文档试图程序打开网络上的文件时的疑问
- 控件怎样随窗口大小而改变,给出源码
- 工具栏按钮菜单为什么显示的位置不对,如何象其他软件中一样紧贴在工具栏按钮下???
- 请各位大哥,大姐帮忙给个windows核心编程的配套代码的url,本人找了很久而未得
- 刚学VC,有个简单的问题
- 关于在api应用程序中使用atl控件的一个问题
- 怎样将一幅真彩色的位图变成灰度图呢?希望C++的源代码,而不是什么控件。
- MFC新手,求教各位大神一个问题
- 请问如何更新自己的Platform SDK库?是不是换了Windows2000就可以了?
- 如何把outlook中的通讯薄中的记录让我编的应用程序可以使用?
CWinApp *app = AfxGetApp();
CMainFrame* pframe = (CMainFrame*)app->m_pMainWnd;
ASSERT(pframe);
pframe->m_pview->OnViewData();
应该可以的。。
可以在框架的cpp文件中包含视的头文件.我的程序就是这么做的喔.
你没在框架的头文件中调用视的东西吧,有的话全搬到CPP中来
//#include "DesignView.h"
#include "stdafx.h"
#include "Design.h"#include "MainFrm.h"````````````````````````````````````````````````````
//MainFrm.h
#define TIMERNUM 100
#include "NewClientWnd.h"
#include "PswDlg.h"
#include "RuKuInint.h"
#include "DBAction.h"
#include "ChangePswDlg.h"
#include "SearchDlg.h"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
本来没有问题,但在MainFrm.cpp里加上
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
CDesignView *pView = (CDesignView *) pChild->GetActiveView();
pView->OnViewData();
就出问题。
错误提示:
D:\mywork\毕业设计\Design\MainFrm.cpp(533) : error C2065: 'CDesignView' : undeclared identifier
D:\mywork\毕业设计\Design\MainFrm.cpp(533) : error C2065: 'pView' : undeclared identifier
D:\mywork\毕业设计\Design\MainFrm.cpp(533) : error C2059: syntax error : ')'
D:\mywork\毕业设计\Design\MainFrm.cpp(534) : error C2227: left of '->OnViewData' must point to class/struct/union不是拼写错误,我都是Ctrl-C、Ctrl-V来的。
#include "stdafx.h"
的顺序倒过来,"stdafx.h"应该是第一个被包含的文件.你的程序是多文档界面吧?
D:\mywork\毕业设计\Design\RuKuInint.h(36) : error C2057: expected constant expression
D:\mywork\毕业设计\Design\DesignView.h(22) : error C2143: syntax error : missing ';' before '*'
D:\mywork\毕业设计\Design\DesignView.h(22) : error C2501: 'CDesignDoc' : missing storage-class or type specifiers
D:\mywork\毕业设计\Design\DesignView.h(22) : error C2501: 'GetDocument' : missing storage-class or type specifiers
D:\mywork\毕业设计\Design\DesignView.h(60) : error C2143: syntax error : missing ';' before '*'
D:\mywork\毕业设计\Design\DesignView.h(60) : error C2433: 'CDesignDoc' : 'inline' not permitted on data declarations
D:\mywork\毕业设计\Design\DesignView.h(60) : error C2501: 'CDesignDoc' : missing storage-class or type specifiers
D:\mywork\毕业设计\Design\DesignView.h(61) : error C2501: 'GetDocument' : missing storage-class or type specifiers
D:\mywork\毕业设计\Design\DesignView.h(61) : error C2059: syntax error : ')'
D:\mywork\毕业设计\Design\MainFrm.cpp(534) : error C2248: 'OnViewData' : cannot access protected member declared in class 'CDesignView'
D:\mywork\毕业设计\Design\DesignView.h(54) : see declaration of 'OnViewData'是MDI的如果方便的话,我的QQ :245134
应该记住在头文件中尽量少的使用包含其他头文件的手法