应用程序GetMessage甚至在MessageBox期间也可以吗? [英] Does the application GetMessage even during MessageBox?

查看:83
本文介绍了应用程序GetMessage甚至在MessageBox期间也可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理WM_TIMER时,我打电话给 MessageBox .结果,出现一个带有计时器频率的消息框.因此,我相信即使在 MessageBox 期间,该应用程序仍试图继续处理已排队/未排队的消息.

While handling WM_TIMER, I called MessageBox. As a result, a message box popped up with the frequency of the timer. So I believe that the application was trying to continue to process queued/non-queued messages even during MessageBox.

我说得对吗?

我知道,根据MSDN,当应用程序将消息发送到发送线程之外的其他线程时,发送线程将尝试处理在 SendMessage 返回之前收到的非排队消息- -即在目标线程回复之前.

I know that according to MSDN, while an application is sending a message to a different thread from the sending thread, the sending thread will try to process non-queued messages it receives before SendMessage returns --- i.e. before the target thread replies.

除了 MessageBox SendMessage 之外,是否还有其他功能可以尝试继续处理排队的/未排队的消息?我需要知道这一点,以确定在Window过程中调用的任何函数是否应该可重入.

Are there any other functions that could try to continue to process queued/non-queued messages before they return, besides MessageBox and SendMessage? I need to know about that to determine whether any functions called in the Window procedure should be reentrant.

另外两个相关的问题是 1) DispatchMessage 会在窗口过程返回之前不返回吗? 2)如果当前的 DispatchMessage 还没有返回,会不会再次调用 GetMessage 吗?

Another two relevant questions are 1) Does DispatchMessage not return until the window procedure has returned? 2) Will GetMessage not be called again if the current DispatchMessage hasn't returned yet?

推荐答案

模式对话框使用调用线程的消息队列在内部运行自己的消息循环.您正在WM_TIMER处理程序中调用MessageBox(),因此MessageBox()内部的消息循环正在运行消息框时接收和分派后续的WM_TIMER消息.

A modal dialog runs its own message loop internally, using the calling thread's message queue. You are calling MessageBox() inside your WM_TIMER handler, so the message loop inside of MessageBox() is receiving and dispatching subsequent WM_TIMER messages while the message box is running.

这篇关于应用程序GetMessage甚至在MessageBox期间也可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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