CCommanBar的关闭按钮不会退出应用程序 [英] Close button of CCommanBar does not exit the application

查看:89
本文介绍了CCommanBar的关闭按钮不会退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用MFC创建智能设备应用程序,以这种方式创建命令栏:

I am creating a smart device application using MFC, that creates a command bar this way:

if (!m_wndCommandBar.Create(this) ||
        !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
        !m_wndCommandBar.AddAdornments(dwAdornmentFlags))
    {
        TRACE0("CommandBar no se pudo crear\n");
        return -1;      // No se pudo crear
    }

    m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() | CBRS_SIZE_FIXED);

这样,a使用关闭按钮创建命令栏。

That way, a command bar is created with a close button.

这是智能设备的SDI应用程序。

This is a SDI application for smart device.

当我按下关闭按钮时,应用程序窗口消失,但应用程序继续运行。我意识到这一点,因为当我使用Visual Studio 2008进行调试时,调试器无法完成。事实上,当视图被破坏时我需要一些清理,
但是析构函数永远不会被调用。

When I press the close button, the application window disappear, but application continues running. I realized about that because when I debug using Visual Studio 2008, the debugger does not finish. And in fact, I need some clean up when the view is destroyed, but the destructor never get called.

我该怎么办?

谢谢

Jaime

由C ++提供支持

推荐答案

您好
Jaime Stuardo,

感谢您在此处发帖。

>> ;当我按下关闭按钮时,应用程序窗口消失,但应用程序继续运行。我意识到这一点,因为当我使用Visual Studio 2008进行调试时,调试器无法完成。事实上,当
视图被销毁时我需要一些清理,但析构函数永远不会被调用。

我该怎么办? / strong>

What can I do?

这是因为CCommanBar上的关闭按钮并没有真正关闭应用程序,只关闭窗口。

This is because the close button on CCommanBar doesn't really close the application, but only close the window.

你可以使用
SendMessage
功能发送一个WM_DESTROY消息,向系统指示线程已发出终止请求(退出)。然后你可以用
$进行清理。 b $ b PostQuitMessage 功能。

You could use SendMessage function to send a WM_DESTROY message which indicates to the system that a thread has made a request to terminate (quit). Then you could do your clean up in PostQuitMessage function.

希望这可以为您提供帮助。

Hope this could be help of you.

最好的问候,

Sera Yu


这篇关于CCommanBar的关闭按钮不会退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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