【问题标题】:Creating CMFCDesktopAlertWnd Control in Visual C++在 Visual C++ 中创建 CMFCDesktopAlertWnd 控件
【发布时间】:2023-04-05 22:38:01
【问题描述】:

MSDN 包含一个创建桌面警报窗口的示例: http://msdn.microsoft.com/en-us/library/bb983515.aspx

示例代码以以下声明开头。

CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd;

当我在我的代码中使用它时,编译器会报错

'CMFCDesktopAlertWnd' : no appropriate default constructor available

这是我的应用程序的完整源代码。 (我在 Visual Studio 中创建了一个空的 Win32 项目并设置 Property | 上的 Use MFC in a Shared DLL 选项一般页面。)

#include <afxwin.h>
#include <afxDesktopAlertDialog.h>

class Notifier : public CWinApp
{
public:
        virtual BOOL InitInstance();
};

BOOL Notifier::InitInstance()
{
        CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd;
        return TRUE;
}

Notifier myApp;

我做错了什么? 在 VS Express 2008 和 VS 2010 完整版中效果是一样的。

【问题讨论】:

    标签: c++ visual-studio mfc desktop-application


    【解决方案1】:
    • 您使用的是 VS 2008 SP1 吗? (服务包很重要)
    • 您是否在 stdafx.h 中包含正确的标头?更具体地说,您需要

      #include

      #include

    能够使用 MFC Next(功能包)类。

    它无论如何都不能在 VS Express 上运行,因为它不包括 MFC。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-30
      • 2015-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 2012-11-10
      相关资源
      最近更新 更多