使用visual c ++的MFC程序

时间:2009-09-02 14:36:14

标签: visual-c++ mfc

在调试基于MFC的Windows应用程序(visual C ++)后,我收到以下警告。问题是它不显示窗口。为什么会这样?

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

代码是:

#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 个答案:

答案 0 :(得分:4)

修正拼写错误:InitInsatnce应为InitInstance,然后您的窗口将被初始化并显示。