tags:

views:

230

answers:

1

I am getting the following warning after I debug the MFC based windows application(visual C++). The problem is that it does not display the window. Why is it so?

Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.
The program '[2616] new.exe: Native' has exited with code 0 (0x0).

The code is:

#include <afxwin.h>
#include "stdafx.h"

class myframe:public CFrameWnd
{
public:
myframe()
{
 Create(0,TEXT("On single Left Mouse Button Click"));
}
void OnLButtonDown(UINT flag,CPoint pt)
{
 CClientDC d(this);
 d.SetTextColor(RGB(0,0,255));
 d.TextOutW(pt.x,pt.y,TEXT("Hello"),5);
}
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

class myapp:public CWinApp
{
public:
 int InitInsatnce()
 {
  myframe *p;
  p=new myframe;
  p->ShowWindow(3);
  m_pMainWnd=p;
     return 1;
 }
};
myapp a;
+1  A: 

Fix the typo: InitInsatnce should be InitInstance then your window will be initialised and displayed.

Steve Beedie