views:

105

answers:

1

Hello,

MSDN contains an example for creating a desktop alert window: http://msdn.microsoft.com/en-us/library/bb983515.aspx

The sample code starts with the following declaration.

CMFCDesktopAlertWnd* pPopup = new CMFCDesktopAlertWnd;

When I use it in my code, the compiler complains

'CMFCDesktopAlertWnd' : no appropriate default constructor available

This is the complete source code of my application. (I created an empty Win32 project in Visual Studio and set the Use MFC in a Shared DLL option on the Property | General page.)

#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;

What am I doing wrong? The effect is the same in VS Express 2008 and the full version of VS 2010.

A: 
  • Are you using VS 2008 SP1? (The service pack is important)
  • Are you including the proper headers in stdafx.h? More specifically, you need

    #include < afxext.h >

    #include < afxcontrolbars.h >

to be able to use MFC Next (feature pack) classes.

It won't work on VS Express anyway because that doesn't include MFC.

Roel