[英]Receive PostMessage messages for MFC Dialog
I have a dialog where the user is able to enter information and then press the Go button. 我有一个对话框,用户可以在其中输入信息,然后按“执行”按钮。 When they press this button I disable the form elements (buttons etc) and create a worker thread using
AfxBeginThread( ... )
. 当他们按下此按钮时,我将禁用表单元素(按钮等),并使用
AfxBeginThread( ... )
创建辅助线程。 Once the worker thread has completed I want it to send a message to the UI thread so as to re-enable the form. 工作线程完成后,我希望它向UI线程发送消息,以便重新启用表单。 I am using
::PostMessage( ... )
to send the message, but I can't find how to intercept these messages. 我正在使用
::PostMessage( ... )
发送消息,但是找不到如何拦截这些消息。
i've searched online ( Link #1 , Link #2 , Link #3 ) but I can't find an understandable example of the code to implement my own message listener. 我已经在线搜索( 链接#1 , 链接#2 , 链接#3 ),但是我找不到实现我自己的消息侦听器的代码的可理解示例。 In the header I can see some crazy define statements (started with
DECLARE_MESSAGE_MAP()
) which looks like it may have something to do with it, but I can't figure it out. 在标题中,我可以看到一些疯狂的define语句(以
DECLARE_MESSAGE_MAP()
开头),看起来可能与它有关,但我无法弄清楚。
Any help is much appreciated. 任何帮助深表感谢。 Thanks.
谢谢。
The message map is a table. 消息映射是一个表。 For each message you are interested in it contains the message and a function pointer to the message handler function.
对于您感兴趣的每条消息,都包含该消息和指向消息处理程序函数的函数指针。 To add a custom message to the map you add an ON_MESSAGE entry to the table.
要将自定义消息添加到地图,请在表中添加ON_MESSAGE条目。 A tutorial example of doing this from a worker thread is here:
这里是从工作线程执行此操作的教程示例:
http://vcfaq.mvps.org/mfc/12.htm http://vcfaq.mvps.org/mfc/12.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.