如何在VC ++(MFC)中创建自己的消息处理程序? [英] How to create own message handler in VC++(MFC) ?

查看:63
本文介绍了如何在VC ++(MFC)中创建自己的消息处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何在MFC中创建自己的MESSAGE?

我用Google搜索,但对此并没有具体想法,也没有创建相同主题的步骤.因此,请指导我理解并在MFC中创建自己的消息.
谢谢:)

Hi,
How can we create our own MESSAGE in MFC?

I Googled but i didn''t get any concrete idea on this and also the steps to create the same. So kindly please guide me to understand and create own message in MFC.
Thanks :)

推荐答案

,您可以使用任何UINT值作为messege值.但是它应该与已经存在的值不同.因此,通常我们创建用户定义消息的操作是

#define MY_CUSTOM_MSG WM_APP + 1

您可以使用sendmessage或postmessage功能发送/发布消息.

然后,您可以在messagemap内为此消息添加一个事件处理程序,如下所示.

ON_MESSAGE( MY_CUSTOM_MSG, OnMyMessage )

如下定义OnMyMessage 十分重要

LRESULT OnMyMessage (WPARAM wParam, LPARAM lParam);

请注意,这种消息对于您的进程来说是本地的,如果要将消息从一个进程发送到另一个进程,则必须使用RegisterWindowMessage [
you can use any UINT value as a messege value. But it should be unique from already existing values. So generally what we does to create a user defined message is

#define MY_CUSTOM_MSG WM_APP + 1

you can sent/post the message using the sendmessage or postmessage function.

And you can add an event handler for this message inside the messagemap as follows.

ON_MESSAGE( MY_CUSTOM_MSG, OnMyMessage )

It is important that you define the OnMyMessage as follows

LRESULT OnMyMessage (WPARAM wParam, LPARAM lParam);

Please note that this kind of message is local to your process, if you want to sent message from one process to another, then you have to create the mesasge using RegisterWindowMessage[^] function. The message map entry for this type of message is ON_REGISTERED_MESSAGE.


检查此链接

Check this link

http://www.google.co.in/#hl=en&source=hp&q=user+defined+messages+in+mfc&oq=User+Defined+message&aq=0&aqi=g3g-m1&aql=t&gs_sm=e&gs_upl=1288l7698l0l27l25l3l5l5l0l363l3332l0.8.7.1&fp=28a30004abcead3a&biw=1280&bih=881[^]


这篇关于如何在VC ++(MFC)中创建自己的消息处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆