自定义的消息只能靠PostMessage() AND SendMessage()进行.
1.定义消息:#define WM_YOURMESSAGE WM_USER+N
2.声名消息处理函数: LRESULT OnMyMessage(WParam,LParam)
3.将消息处理函数与消息关联:ON_MESSAGE(WM_YOURMESSAGE,OnMyMessage)
4.实现消息处理函数如:LRESULT CAppurView::OnMyMessage(wparam,lparam)
{......}
5.放送消息.如在OnLBottonDown()调用:PostMessage(WM_YOURMEssage,1,2)
1--->wparam,2----->lparam
第三步的代码因放在类似于下面的地方
BEGIN_MESSAGE_MAP(CViewView, CView)
//{{AFX_MSG_MAP(CViewView)
/ NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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
添加ON_MESSAGE(WM_YOURMESSAGE,OnMyMessage)
END_MESSAGE_MAP()