0
Je reçois l'avertissement suivant après avoir débogué l'application Windows MFC (Visual C++). Le problème est qu'il n'affiche pas la fenêtre. Pourquoi est-ce vrai?Programme MFC utilisant Visual C++
Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application. The program '[2616] new.exe: Native' has exited with code 0 (0x0).
Le code est:
#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;
d'abord: myframe() Deuxièmement, pouvons-nous voir le code pour myframe? –
Oh mon garçon dois-je avoir des pouvoirs d'édition ... –
n'est pas "InitInsatnce" une faute de frappe? Avez-vous cela dans votre vrai code? – djeidot