为什么 PeekMessage 总是返回 TRUE? [英] Why the PeekMessage always return TRUE?

查看:47
本文介绍了为什么 PeekMessage 总是返回 TRUE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

        // Main message loop

        MSG msg;
        ZeroMemory( &msg, sizeof( msg ) );
        while(msg.message!=WM_QUIT)
        {

            if(PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
            {
                TranslateMessage( &msg );
                DispatchMessage( &msg );
            }
            else
            {
                Render();
            }
        }

渲染"函数尚未执行

推荐答案

PeekMessage 文档说明了有关返回值的内容:

The PeekMessage documentation says this regarding the return value:

如果消息可用,则返回值非零.

If a message is available, the return value is nonzero.

如果没有可用消息,则返回值为零.

If no messages are available, the return value is zero.

当消息队列为空时,确实会返回零,即FALSE.因此结论是消息队列永远不会为空.对此最可能的解释是,您在 DispatchMessage 中处理的消息之一导致将同一条消息发布到队列中.

When the message queue is empty, it will indeed return zero, i.e. FALSE. The conclusion therefore is that the message queue is never empty. And the most likely explanation for that is that one of the messages you handle in DispatchMessage leads to that same message being posted to the queue.

这篇关于为什么 PeekMessage 总是返回 TRUE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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