程序用途
  简单的画图(鼠标)
程序代码如下
#include"afxwin.h"
#include"Message.h"//资源文件头class MyFrame:public CFrameWnd{//窗体类
private:
CMenu *FMenu;
public:
//构造和析构
MyFrame(){
Create(NULL,"Painting");
FMenu=new CMenu;
FMenu->LoadMenu(IDR_MENU1);
SetMenu(FMenu);
}
~MyFrame(){
delete FMenu;
}
//对消息的响应
afx_msg void OnExit(){//菜单的一项
MessageBox("Exit");
DestroyWindow();
}
afx_msg void OnLButtonDown(UINT nFlags,CPoint point){
SetCapture();
}
afx_msg void OnMouseMove(UINT nFlags,CPoint point){
if(this==GetCapture()){
CClientDC aDC(this);
aDC.SetPixel(point,RGB(225,0,0));
}
}
afx_msg void OnLButtonUp(UINT nFlags,CPoint point){
ReleaseCapture();
}
DECLARE_MESSAGE_MAP();
};BEGIN_MESSAGE_MAP (MyFrame,CFrameWnd)
  ON_COMMAND(IDM_EXIT,OnExit)
  ON_WM_LBUTTONDOWN()
  ON_WM_MOUSEMOVE()
  ON_WM_LBUTTONUP()
END_MESSAGE_MAP()class MyApp:public CWinApp{
public:
  BOOL InitInstance(){
    CFrameWnd *Frame=new MyFrame();
    m_pMainWnd=Frame;
    Frame->ShowWindow(SW_SHOW);
    return TRUE;
    }
};
MyApp A_App;