#include <afxwin.h>
class MyApp :public CWinApp//app類
{
public:
virtual BOOL InitInstance();//重寫父類的初始化函數
};
class MyFrame :public CFrameWnd//窗口框架類
{
public:
MyFrame();//窗口類構造函數
DECLARE_MESSAGE_MAP()//消息映射機制的聲明宏
////鼠標點擊處理函數的聲明
afx_msg void OnLButtonDown(UINT, CPoint);
};
#include "mfc.h"
MyApp app;
BOOL MyApp::InitInstance()
{
MyFrame * pFrame = new MyFrame;
//pFrame->Create(NULL, TEXT("mfc"));
pFrame->ShowWindow(SW_SHOWNORMAL);
pFrame->UpdateWindow();
m_pMainWnd = pFrame;
return TRUE;
}
//消息映射分界宏,相當於消息處理函數
BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd)
ON_WM_LBUTTONDOWN()//鼠標左鍵按下的映射入口,消息映射根據映射入口找到 afx_msg void OnLButtonDown( UINT, CPoint )
//#define ON_WM_LBUTTONDOWN( ) afx_msg void OnLButtonDown( UINT, CPoint )
END_MESSAGE_MAP()
MyFrame::MyFrame()
{
//pFrame->Create(NULL, TEXT("mfc"));
Create(NULL, TEXT("mfc"));
}
//鼠標點擊處理函數的實現
void MyFrame::OnLButtonDown(UINT, CPoint)
{
CString str;
str.Format(TEXT("%d %d"), 10, 20);
MessageBox(str);
}