各位大侠看看吧:小弟等待中。。// My_ResView.cpp : implementation of the CMy_ResView class
//#include "stdafx.h"
#include "My_Res.h"#include "My_ResDoc.h"
#include "My_ResView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMy_ResViewIMPLEMENT_DYNCREATE(CMy_ResView, CView)BEGIN_MESSAGE_MAP(CMy_ResView, CView)
//{{AFX_MSG_MAP(CMy_ResView)
ON_COMMAND(ID_OPER_SHOW, OnOperShow)//消息绑定
ON_UPDATE_COMMAND_UI(ID_OPER_SHOW, OnUpdateOperShow)
ON_UPDATE_COMMAND_UI_RANGE(ID_OPER_RED,ID_OPER_BLUE,OnUpdateOperColorChange)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND_RANGE(ID_OPER_RED,ID_OPER_BLUE,OnOperColorChange)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMy_ResView construction/destructionCMy_ResView::CMy_ResView()
{
// TODO: add construction code here
m_nColors[0]=RGB(255,0,0);
m_nColors[1]=RGB(0,255,0);
m_nColors[2]=RGB(0,0,255);
m_nColorIndex=0;
m_strShow="Hello World!";
m_bShow=TRUE;}CMy_ResView::~CMy_ResView()
{
}BOOL CMy_ResView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs return CView::PreCreateWindow(cs);
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView drawingvoid CMy_ResView::OnDraw(CDC* pDC)
{
CMy_ResDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(m_bShow)
{
pDC->SetTextColor(m_nColors[m_nColorIndex]);
pDC->TextOut(100,100,m_strShow);
}
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView printingBOOL CMy_ResView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}void CMy_ResView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}void CMy_ResView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView diagnostics#ifdef _DEBUG
void CMy_ResView::AssertValid() const
{
CView::AssertValid();
}void CMy_ResView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}CMy_ResDoc* CMy_ResView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy_ResDoc)));
return (CMy_ResDoc*)m_pDocument;
}
#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
// CMy_ResView message handlersvoid CMy_ResView::OnOperShow()
{
// TODO: Add your command handler code here
m_bShow=!m_bShow;
Invalidate();//强制程序重新窗口
}void CMy_ResView::OnUpdateOperShow(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bShow);
}
void CMy_ResView::OnOperColorChange(WORD nID)
{
m_nColorIndex=nID-ID_OPER_RED;
Invalidate();
}
void CMy_ResView::OnOperColorChange(CCmdUI * pCmdUI)
{
pCmdUI->SetRadio(m_nColorIndex==(pCmdUI->m_nID-ID_OPER_RED));
}
以下是错误信息的提示:--------------------Configuration: My_Res - Win32 Debug--------------------
Compiling...
My_ResView.cpp
F:\vc++6.0\MSDev98\MyProjects\My_Res\My_ResView.cpp(139) : error C2511: 'OnOperColorChange' : overloaded member function 'void (class CCmdUI *)' not found in 'CMy_ResView'
f:\vc++6.0\msdev98\myprojects\my_res\my_resview.h(13) : see declaration of 'CMy_ResView'
Error executing cl.exe.My_Res.exe - 1 error(s), 0 warning(s)
//#include "stdafx.h"
#include "My_Res.h"#include "My_ResDoc.h"
#include "My_ResView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMy_ResViewIMPLEMENT_DYNCREATE(CMy_ResView, CView)BEGIN_MESSAGE_MAP(CMy_ResView, CView)
//{{AFX_MSG_MAP(CMy_ResView)
ON_COMMAND(ID_OPER_SHOW, OnOperShow)//消息绑定
ON_UPDATE_COMMAND_UI(ID_OPER_SHOW, OnUpdateOperShow)
ON_UPDATE_COMMAND_UI_RANGE(ID_OPER_RED,ID_OPER_BLUE,OnUpdateOperColorChange)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND_RANGE(ID_OPER_RED,ID_OPER_BLUE,OnOperColorChange)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMy_ResView construction/destructionCMy_ResView::CMy_ResView()
{
// TODO: add construction code here
m_nColors[0]=RGB(255,0,0);
m_nColors[1]=RGB(0,255,0);
m_nColors[2]=RGB(0,0,255);
m_nColorIndex=0;
m_strShow="Hello World!";
m_bShow=TRUE;}CMy_ResView::~CMy_ResView()
{
}BOOL CMy_ResView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs return CView::PreCreateWindow(cs);
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView drawingvoid CMy_ResView::OnDraw(CDC* pDC)
{
CMy_ResDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if(m_bShow)
{
pDC->SetTextColor(m_nColors[m_nColorIndex]);
pDC->TextOut(100,100,m_strShow);
}
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView printingBOOL CMy_ResView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}void CMy_ResView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}void CMy_ResView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}/////////////////////////////////////////////////////////////////////////////
// CMy_ResView diagnostics#ifdef _DEBUG
void CMy_ResView::AssertValid() const
{
CView::AssertValid();
}void CMy_ResView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}CMy_ResDoc* CMy_ResView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy_ResDoc)));
return (CMy_ResDoc*)m_pDocument;
}
#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
// CMy_ResView message handlersvoid CMy_ResView::OnOperShow()
{
// TODO: Add your command handler code here
m_bShow=!m_bShow;
Invalidate();//强制程序重新窗口
}void CMy_ResView::OnUpdateOperShow(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bShow);
}
void CMy_ResView::OnOperColorChange(WORD nID)
{
m_nColorIndex=nID-ID_OPER_RED;
Invalidate();
}
void CMy_ResView::OnOperColorChange(CCmdUI * pCmdUI)
{
pCmdUI->SetRadio(m_nColorIndex==(pCmdUI->m_nID-ID_OPER_RED));
}
以下是错误信息的提示:--------------------Configuration: My_Res - Win32 Debug--------------------
Compiling...
My_ResView.cpp
F:\vc++6.0\MSDev98\MyProjects\My_Res\My_ResView.cpp(139) : error C2511: 'OnOperColorChange' : overloaded member function 'void (class CCmdUI *)' not found in 'CMy_ResView'
f:\vc++6.0\msdev98\myprojects\my_res\my_resview.h(13) : see declaration of 'CMy_ResView'
Error executing cl.exe.My_Res.exe - 1 error(s), 0 warning(s)
afx_msg void OnOperColorChange(CCmdUI* pCmdUI);