| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 665 人关注过本帖
标题:MFC中出现的错误,谢谢大神们,望帮忙
只看楼主 加入收藏
igoodstudy
Rank: 1
等 级:新手上路
帖 子:3
专家分:1
注 册:2012-10-15
结帖率:100%
收藏
 问题点数:0 回复次数:0 
MFC中出现的错误,谢谢大神们,望帮忙
代码是这样的:void CCp1_5View::OnMenuitemNew()
{
    // TODO: Add your command handler code here
    //获取文档类指针
    CCp1_5Doc *pDoc=GetDocument();

    //获取ImgCenterDib类对象的指针,访问打开文件的数据
    ImgCenterDib *pDib=pDoc->GetPDib();

    //位图数据的指针
    unsigned char* imgData=pDib->m_pImgData;
   
    //位图阵列的大小
    CSize imgSize=pDib->GetDimensions();


    //每像素的位数
    int nBitCount=pDib->m_nBitCount;
   
    //循环变量,图像坐标
    int i,j;

    //每像素占字节数
    int bytePerPixel=nBitCount/8;

    //每行像素所占字节数,必须是4的倍数
    int lineByte=(imgSize.cx*nBitCount/8+3)/4*4;
    //循环变量,每像素各字节(分量)访问的循环变量
    int k;
//申请缓冲区pBuf
    unsigned char* pBuf=new unsigned char[lineByte*imgSize.cy];
//将原DIB位图数据拷贝至pBuf
    memcpy(pBuf,imgData,lineByte*imgSize.cy);
   
    //将pBuf左下角1/4部分置黑色
    for(i=0;i<imgSize.cy/2;i++){
        for(j=0;j<imgSize.cx/2;j++){
            for(k=0;k<bytePerPixel;k++){
                *(pBuf+i*lineByte+j*bytePerPixel+k)=0;
            }
        }
    }


//打开新视图,显示分割结果
CMainFrame *pFrame=(CMainFrame *)(AfxGetApp()->m_pMainWnd);

//发送一个新建文件的消息,创建一个新的文档视图
pFrame->SendMessage(WM_COMMAND,ID_FILE_NEW);

//获取新建视图的指针
CCp1_5View* pView=(CCp1_5View*)pFrame->MDIGetActive()->GetActiveView();

//获取相关联的新的文档类指针
CCp1_5Doc* pDocNew=pView->GetDocument();

//获取新文档中的ImgCenterDib类对象指针
ImgCenterDib *dibNew=pDocNew->GetPDib();

//调用ReplaceDib,用改变以后的位图数据替换原位图
dibNew->ReplaceDib(imgSize,nBitCount,pDib->m_lpColorTable,pBuf);

//设置滚动窗口
pView->OnInitialUpdate();

//文档数据置脏,提示存盘信息
pDocNew->SetModifiedFlag(TRUE);

//各视图刷新显示
pDocNew->UpdateAllViews(pView);
}


但是编译时候的错误时:f:\vc编程\cp1_5\cp1_5view.cpp(4) : warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
F:\VC编程\cp1_5\cp1_5View.cpp(235) : error C2065: 'CMainFrame' : undeclared identifier
F:\VC编程\cp1_5\cp1_5View.cpp(235) : error C2065: 'pFrame' : undeclared identifier
F:\VC编程\cp1_5\cp1_5View.cpp(235) : error C2059: syntax error : ')'
F:\VC编程\cp1_5\cp1_5View.cpp(238) : error C2227: left of '->SendMessageA' must point to class/struct/union
F:\VC编程\cp1_5\cp1_5View.cpp(241) : error C2227: left of '->MDIGetActive' must point to class/struct/union
F:\VC编程\cp1_5\cp1_5View.cpp(241) : error C2227: left of '->GetActiveView' must point to class/struct/union
Error executing cl.exe.

cp1_5.exe - 6 error(s), 1 warning(s)



如果,我再View中加入#include“MainFrm.h”
则错误变为:
Linking...
cp1_5Doc.obj : error LNK2001: unresolved external symbol "public: __thiscall ImgCenterDib::ImgCenterDib(void)" (??0ImgCenterDib@@QAE@XZ)
cp1_5Doc.obj : error LNK2001: unresolved external symbol "public: __thiscall ImgCenterDib::~ImgCenterDib(void)" (??1ImgCenterDib@@QAE@XZ)
cp1_5Doc.obj : error LNK2001: unresolved external symbol "public: int __thiscall ImgCenterDib::Read(char const *)" (?Read@ImgCenterDib@@QAEHPBD@Z)
cp1_5View.obj : error LNK2001: unresolved external symbol "public: int __thiscall ImgCenterDib::Draw(class CDC *,class CPoint,class CSize)" (?Draw@ImgCenterDib@@QAEHPAVCDC@@VCPoint@@VCSize@@@Z)
cp1_5View.obj : error LNK2001: unresolved external symbol "public: class CSize __thiscall ImgCenterDib::GetDimensions(void)" (?GetDimensions@ImgCenterDib@@QAE?AVCSize@@XZ)
cp1_5View.obj : error LNK2001: unresolved external symbol "public: void __thiscall ImgCenterDib::ReplaceDib(class CSize,int,struct tagRGBQUAD *,unsigned char *)" (?ReplaceDib@ImgCenterDib@@QAEXVCSize@@HPAUtagRGBQUAD@@PAE@Z)
Debug/cp1_5.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.

cp1_5.exe - 7 error(s), 1 warning(s)


后来我把#include“MainFrm.h”
故意写成#include"MainFrame.h"
错误提示成为:f:\vc编程\cp1_5\cp1_5view.cpp(4) : warning C4652: compiler option 'Generate Browser Info' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
F:\VC编程\cp1_5\cp1_5View.cpp(10) : fatal error C1083: Cannot open include file: 'MainFrame.h': No such file or directory
Error executing cl.exe.

cp1_5.exe - 1 error(s), 1 warning(s)
虽然MainFrame.h文件根本不存在,但是错误竟然减少了。实在不明白这些是为什么
搜索更多相关主题的帖子: command void 
2012-10-18 21:17
快速回复:MFC中出现的错误,谢谢大神们,望帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014120 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved