第一部分“DrawView.h”头文件,“函数原型声明”
//DrawView.h : interface of the CDrawView class
//
////////////////////////////////////////////////////////////class CDrawView : public CView
{
protected: // create from serialization only
CDrawView();
DECLARE_DYNCREATE()
...................................
//Generated message map funtions
protected:
//{{AFX_MSG(CDrawView)
afx_msg void OnLButtonDown(UINT nFlags , CPoint point); //函数原型声明
//}}AFX_MSG
问题一:“//{{AFX_MSG(CDrawView) //}}AFX_MSG”这样注释宏的作用是什么???为什么要使用它???
DECLARE_MESSAGE_MAP()
问题二:在这里声明“DECLARE_MESSAGE_MAP()”映射的作用是什么???和下面的“BEGIN_MESSAGE_MAP END_MESSAGE_MAP()”是不是有什么关系???
}第二部分“DrawView.cpp”中的“消息映射宏”和“消息响应函数”
//DrawView.cpp : implementation of the CDrawView class
IMPLEMENT_DYNCREATE(CDrawView, CView)
问题三:这个干什么使得???
BEGIN_MESSAGE_MAP(CDrawView , CView)
//{{AFX_MSG_MAP(CDrawView)
ON_WM_LBUTTONDOWN() //消息映射宏
//}}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)
问题五:这些是不是类“CDrawView”默认自带的一些消息处理函数,在MFC中默认内置的呢???
END_MESSAGE_MAP()//CDrawView message handlers
void CDrawView : : OnLButtonDown(UINT nFlags , CPoint point) //消息响应函数的实现
{
// TODO: Add your message handler code here and/or call default
MessageBox("View Clicked!");
CView::OnLButtonDown(nFlags,point);
}
//DrawView.h : interface of the CDrawView class
//
////////////////////////////////////////////////////////////class CDrawView : public CView
{
protected: // create from serialization only
CDrawView();
DECLARE_DYNCREATE()
...................................
//Generated message map funtions
protected:
//{{AFX_MSG(CDrawView)
afx_msg void OnLButtonDown(UINT nFlags , CPoint point); //函数原型声明
//}}AFX_MSG
问题一:“//{{AFX_MSG(CDrawView) //}}AFX_MSG”这样注释宏的作用是什么???为什么要使用它???
DECLARE_MESSAGE_MAP()
问题二:在这里声明“DECLARE_MESSAGE_MAP()”映射的作用是什么???和下面的“BEGIN_MESSAGE_MAP END_MESSAGE_MAP()”是不是有什么关系???
}第二部分“DrawView.cpp”中的“消息映射宏”和“消息响应函数”
//DrawView.cpp : implementation of the CDrawView class
IMPLEMENT_DYNCREATE(CDrawView, CView)
问题三:这个干什么使得???
BEGIN_MESSAGE_MAP(CDrawView , CView)
//{{AFX_MSG_MAP(CDrawView)
ON_WM_LBUTTONDOWN() //消息映射宏
//}}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)
问题五:这些是不是类“CDrawView”默认自带的一些消息处理函数,在MFC中默认内置的呢???
END_MESSAGE_MAP()//CDrawView message handlers
void CDrawView : : OnLButtonDown(UINT nFlags , CPoint point) //消息响应函数的实现
{
// TODO: Add your message handler code here and/or call default
MessageBox("View Clicked!");
CView::OnLButtonDown(nFlags,point);
}
楼主花时间研读一下这本,自然会有收获,自己理解后才会真正的掌握,要不然即使现在别人跟你说了,你知道了,保不了过几天你不会忘记.难道你连一点阅读的时间都没有嘛?
其它所有的答案你可以从侯杰的MFC深入浅出一书中找到答案
2.DECLARE_MESSAGE_MAP()之后会转到源文件,将消息与消息响应函数关联起来
4.将消息与消息响应函数关联起来