代码和错误提示在下面 ,已经加入#include "MainFrm.h",实在不知道问题出在哪里,希望大家能帮帮我,谢谢了
{
//获取文档类指针
CSecondDoc *pDoc=GetDocument();
//获取ImgCenterDib类对象m_dib的指针,访问当前DIB数据
ImgCenterDib *pDib=pDoc->GetPDib();
//只处理彩色图像
if(pDib->m_nBitCount!=24){
::MessageBox(0,"只处理彩色图像",MB_OK,0);
return ;
}
//将pDib中的图像数据作为输入数据,调用带参数的构造函数,
//定义GrayTrans类的对象graytrans
GrayTrabs graytrans(pDib->GetDimensions(),pDib->m_nBitCount,
pDib->m_lpColorTable, pDib->m_pImgData);
//彩色变灰度格式
graytrans.ColorToGray();
//建立一个新视图,显示分割结果
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
//发送新建文件的消息,创建一个新的文档-视图
pFrame->SendMessage(WM_COMMAND, ID_FILE_NEW);
//获取新建视图指针
CSecondView* pView=(CSecondView*)pFrame->MDIGetActive()->GetActiveView();
//获取相关联的新的文档类指针
CSecondDoc* pDocNew=pView->GetDocument(); //获取新文档中的ImgCenterDib类对象指针
ImgCenterDib *dibNew=pDocNew->GetPDib(); //将变换后的输出图像作为新建文档的DIB进行显示
dibNew->ReplaceDib(graytrans.GetDimensions(),graytrans.m_nBitCountOut,
graytrans.m_lpColorTableOut, graytrans.m_pImgDataOut);
//设置滚动窗口
pView->OnInitialUpdate(); //文档数据置脏,提示存盘信息
pDocNew->SetModifiedFlag(TRUE); //各视图刷新显示
pDocNew->UpdateAllViews(pView);
}
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2065: 'CMainFrame' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2065: 'pFrame' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2059: syntax error : ')'
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(246) : error C2227: left of '->SendMessageA' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(249) : error C2227: left of '->MDIGetActive' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(249) : error C2227: left of '->GetActiveView' must point to class/struct/union
Error executing cl.exe.second.exe - 6 error(s), 0 warning(s)
{
//获取文档类指针
CSecondDoc *pDoc=GetDocument();
//获取ImgCenterDib类对象m_dib的指针,访问当前DIB数据
ImgCenterDib *pDib=pDoc->GetPDib();
//只处理彩色图像
if(pDib->m_nBitCount!=24){
::MessageBox(0,"只处理彩色图像",MB_OK,0);
return ;
}
//将pDib中的图像数据作为输入数据,调用带参数的构造函数,
//定义GrayTrans类的对象graytrans
GrayTrabs graytrans(pDib->GetDimensions(),pDib->m_nBitCount,
pDib->m_lpColorTable, pDib->m_pImgData);
//彩色变灰度格式
graytrans.ColorToGray();
//建立一个新视图,显示分割结果
CMainFrame* pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
//发送新建文件的消息,创建一个新的文档-视图
pFrame->SendMessage(WM_COMMAND, ID_FILE_NEW);
//获取新建视图指针
CSecondView* pView=(CSecondView*)pFrame->MDIGetActive()->GetActiveView();
//获取相关联的新的文档类指针
CSecondDoc* pDocNew=pView->GetDocument(); //获取新文档中的ImgCenterDib类对象指针
ImgCenterDib *dibNew=pDocNew->GetPDib(); //将变换后的输出图像作为新建文档的DIB进行显示
dibNew->ReplaceDib(graytrans.GetDimensions(),graytrans.m_nBitCountOut,
graytrans.m_lpColorTableOut, graytrans.m_pImgDataOut);
//设置滚动窗口
pView->OnInitialUpdate(); //文档数据置脏,提示存盘信息
pDocNew->SetModifiedFlag(TRUE); //各视图刷新显示
pDocNew->UpdateAllViews(pView);
}
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2065: 'CMainFrame' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2065: 'pFrame' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(243) : error C2059: syntax error : ')'
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(246) : error C2227: left of '->SendMessageA' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(249) : error C2227: left of '->MDIGetActive' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\second\secondView.cpp(249) : error C2227: left of '->GetActiveView' must point to class/struct/union
Error executing cl.exe.second.exe - 6 error(s), 0 warning(s)
#include "stdafx.h"下面
或许还有其他的顺序问题 总值 你换下位置 在看看~~
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_NEW);