下列代码中响应鼠标左键按下的句柄名称为 void OnLButtonDown(UINT nFlags, CPoint point); 是不是这一名称是固定的,比如我不能把它改作 void OnMyButtonDown(UINT nFlags, CPoint point)? 如果是固定名称,那么从哪里可以查到这些固定名称的列表?必须都记住么?还有,句柄实现中有这么一行:CFrameWnd::OnLButtonDown(nFlags, point); 它的作用是什么?为什么我把它去掉之后,程序依然可以正常运行?#include <afxwin.h>class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL,"MFC Tutorial Part 2 CoderSource Window");
}
void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_WM_LBUTTONDOWN() //Macro to map the left button click to the handler
END_MESSAGE_MAP()void MFC_Tutorial_Window::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnLButtonDown(nFlags, point);
MessageBox("Left Button clicked");
}
class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;?
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};MyApp theApp;
{
public:
MFC_Tutorial_Window()
{
Create(NULL,"MFC Tutorial Part 2 CoderSource Window");
}
void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_WM_LBUTTONDOWN() //Macro to map the left button click to the handler
END_MESSAGE_MAP()void MFC_Tutorial_Window::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnLButtonDown(nFlags, point);
MessageBox("Left Button clicked");
}
class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;?
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};MyApp theApp;
OnLButtonDown的名称你去看看鼠标左键消息映射宏的具体定义就知道了
ON_MESSAG(WM_lbuttondown,FUNCtion);