VC 自定义消息 postmessage用法
2012-11-29 15:18
274 查看
VC 自定义消息 postmessage用法
1. 在 resource.h文件添加如下代码 定一个自己的消息
#define WM_MY_MESSAGE WM_USER + 100 //---------------------by tyds
2.在...view.h的文件添加如下:
//{{AFX_MSG(CPostmessageView)
afx_msg void Ontydspostmessage();
afx_msg /*LRESULT*/ void OnMyMessage(/*WPARAM wParam, LPARAM lParam*/); //----- by tyds
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
3.在...view.cpp文件添加如下代码
BEGIN_MESSAGE_MAP(CPostmessageView, CView)
//{{AFX_MSG_MAP(CPostmessageView)
ON_COMMAND(ID_tyds_postmessage, Ontydspostmessage)
ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage) //添加消息映射---------------------by tyds
//}}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)
END_MESSAGE_MAP()
void CPostmessageView::Ontydspostmessage()
{
MessageBox("begin post message!");
//PostMessage(WM_MY_MESSAGE); //这里 PostMessage SendMessage 两则区别是
SendMessage(WM_MY_MESSAGE); //PostMessage 是发出去就返回 而SendMessage是发出去等到被 //执行了 在返回
}
消息相应函数
/*LPESULT*/void CPostmessageView::OnMyMessage(/*WPARAM wParam, LPARAM lParam*/) //注意这里 的参数可要可不要 根据自己来定 返回值也一样
{
MessageBox("post msg finished!");
// return 0;
}
转自:http://blog.csdn.net/nnsword/article/details/2976844#
1. 在 resource.h文件添加如下代码 定一个自己的消息
#define WM_MY_MESSAGE WM_USER + 100 //---------------------by tyds
2.在...view.h的文件添加如下:
//{{AFX_MSG(CPostmessageView)
afx_msg void Ontydspostmessage();
afx_msg /*LRESULT*/ void OnMyMessage(/*WPARAM wParam, LPARAM lParam*/); //----- by tyds
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
3.在...view.cpp文件添加如下代码
BEGIN_MESSAGE_MAP(CPostmessageView, CView)
//{{AFX_MSG_MAP(CPostmessageView)
ON_COMMAND(ID_tyds_postmessage, Ontydspostmessage)
ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage) //添加消息映射---------------------by tyds
//}}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)
END_MESSAGE_MAP()
void CPostmessageView::Ontydspostmessage()
{
MessageBox("begin post message!");
//PostMessage(WM_MY_MESSAGE); //这里 PostMessage SendMessage 两则区别是
SendMessage(WM_MY_MESSAGE); //PostMessage 是发出去就返回 而SendMessage是发出去等到被 //执行了 在返回
}
消息相应函数
/*LPESULT*/void CPostmessageView::OnMyMessage(/*WPARAM wParam, LPARAM lParam*/) //注意这里 的参数可要可不要 根据自己来定 返回值也一样
{
MessageBox("post msg finished!");
// return 0;
}
转自:http://blog.csdn.net/nnsword/article/details/2976844#
相关文章推荐
- VC自定义消息postmessage用法(消息响应函数)
- vc中SendMessage自定义消息函数用法实例
- VC中自定义消息ON_MESSAGE的用法
- Vc/MFC中自定义消息及其PostMessage触发使用
- VC++ 添加自定义消息响应函数以及发送消息SendMessage投递消息PostMessage的简单测试
- MFC自定义消息用法总结
- VC 自定义消息 postmessage用法
- 关于VC++中,两种自定义消息的发送与接收的方法实现进行说明
- VC中自定义消息的处理
- VC中添加自定义消息的方法
- VC中使用自定义消息在进程间通讯
- VC中自定义消息响应函数
- VC中的自定义消息(收藏)
- 关于VC++中,两种自定义消息的发送与接收的方法实现进行说明。
- VC++中添加响应自定义消息
- vc自定义消息的发送与接收的方法实现
- vc中怎么使用SendMessage自定义消息函数
- VC中的自定义消息
- VC++中使用用户自定义消息及自定制窗口技巧
- VC中如何使用自定义消息?