0

I have just started working on CDialog classes. When I try to execute the following code, I am getting debug assertion failure.

#include "stdafx.h"
#include "resource.h"
#include <afxwin.h>
#include "dialog.h"
#include <Windows.h>


int _tmain(int argc, _TCHAR* argv[])
{
    dialog dial(NULL);
    dial.DoModal();
    return 0;
}

I have created a dialog resource and CDialogEx class named dialog. The error I am getting is "Debug Assertion Failed!

Program: ...pp_projects\ConsoleApplication1\Debug\ConsoleApplication1.exe File: f:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl Line: 24" Can anyone give me a solution?

Eric
  • 336
  • 4
  • 17
Kumar
  • 616
  • 1
  • 18
  • 39
  • Why do you try to implement a modal UI, only to pass in `NULL` as the owner window. What effect did you expect the call of `DoModal` to have? – IInspectable Apr 29 '14 at 06:34
  • @IInspectable In the MSDN page it is mentioned that NULL should be passed to set the dialog object's parent window to the main application window. So i kept it like that. But I really cant understand what they mean.. – Kumar Apr 29 '14 at 06:58
  • What *main application window* are you talking about? You have none. And please do provide your `dialog` implementation. – IInspectable Apr 29 '14 at 07:08

1 Answers1

4

Your project name suggests that you have created a Win32 Console Application project and added the MFC stuff. What you need to create is a MFC Application project.

MFC can also be used in a console application, but then you would not show dialogs and you would need to initialize MFC first.

Werner Henze
  • 16,404
  • 12
  • 44
  • 69