在Win32创建自定义消息类型? [英] Creating custom message types in win32?
问题描述
有没有一种方法来定义和在Win32中发送自定义消息类型,由您的主要消息处理程序被抓?例如,我的主要消息处理程序捕获的信息,如WM_PAINT,WM_RESIZE,WM_LBUTTONDOWN等。我可以创建自己的WM_DOSOMETHING?如果是这样,我怎么会发这个消息?
Is there a way to define and send custom message types in Win32, to be caught by your Main message handler? For example, my main message handler captures messages such as WM_PAINT, WM_RESIZE, WM_LBUTTONDOWN etc. Can I create my own WM_DOSOMETHING? If so, how would I send this message?
嗯,其实我刚发现这是之前<一问href=\"http://stackoverflow.com/questions/293723/how-could-i-create-a-custom-windows-message\">here,但是,它并没有回答我怎么会实际发送此消息。
Ah, I actually just discovered this was asked before here, however, it doesn't answer how I would actually send this message.
推荐答案
是的。只需要声明一个恒定的范围内WM_USER例如
Yes. Just declare a constant in the WM_USER range e.g.
#define WM_RETICULATE_SPLINES (WM_USER + 0x0001)
您也可以通过名称使用RegisterWindowMessage API注册的消息。
You can also register a message by name using the RegisterWindowMessage API.
您可以然后使用SendMessage函数,PostMessage的或任何其变种发送这些消息。
You can then send these messages using SendMessage, PostMessage or any of their variants.
这篇关于在Win32创建自定义消息类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!