PostQuitMessage()和DestroyWindow()之间的逻辑差别是什么? [英] What's the logical difference between PostQuitMessage() and DestroyWindow()?

查看:927
本文介绍了PostQuitMessage()和DestroyWindow()之间的逻辑差别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的演示样例应用程序

In my demo kinda app

case WM_CLOSE:
    DestroyWindow(hndl);
    return 0;

case WM_CLOSE:
    PostQuitMessage(0);
    return 0;

打电话时,窗帘背后有什么不同?是DestroyWindow更直接,因为PostQuitMessage必须通过getmessage循环返回false?

do the same. What's different behind the curtains when calling each? Is DestroyWindow more direct, where as PostQuitMessage has to go through the getmessage loop returning false?

推荐答案

DestroyWindow ( )会销毁窗口(惊喜)并发布 WM_DESTROY (您还会收到 WM_NCDESTROY )到消息队列。这是 WM_CLOSE 的默认行为。然而,只是因为窗口被销毁并不意味着消息循环应该结束。这可以是具有在关闭时结束应用程序的特定窗口以及在关闭时对应用程序没有作用的其他窗口(例如,选项页)的情况。

DestroyWindow destroys the window (surprise) and posts a WM_DESTROY (you'll also get a WM_NCDESTROY) to the message queue. This is the default behaviour of WM_CLOSE. However, just because a window was destroyed does not mean the message loop should end. This can be the case for having a specific window that ends the application when closed and others that do nothing to the application when closed (e.g., an options page).

code> PostQuitMessage 向消息队列发送一个 WM_QUIT ,通常导致消息循环结束。例如, GetMessage 将在拉出 WM_QUIT 时返回0。这通常在主窗口的 WM_DESTROY 处理程序中调用。这不是默认行为;你必须自己做。

PostQuitMessage posts a WM_QUIT to the message queue, often causing the message loop to end. For example, GetMessage will return 0 when it pulls a WM_QUIT out. This would usually be called in the WM_DESTROY handler for your main window. This is not default behaviour; you have to do it yourself.

这篇关于PostQuitMessage()和DestroyWindow()之间的逻辑差别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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