I tried to shorten a foreign code. I thougth I could save one variable.
The following given code is OK and shows a Windows Frame.
#include <afxwin.h>
// from source: http://www.codersource.net/2010/01/30/mfc-tutorial-part-1/
class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL, "MFC Tutorial Part 1 CoderSource Window");
}
};
class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};
MyApp theApp;
After my rewording it doesn`t function anymore. No build errors. But it doesn't show a frame.
#include <afxwin.h>
// from source: http://www.codersource.net/2010/01/30/mfc-tutorial-part-1/
// and changed by me
class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL, "MFC Tutorial Part 1 CoderSource Window");
}
};
class MyApp :public CWinApp
{
// del MFC_Tutorial_Window *wnd;
MFC_Tutorial_Window *m_pMainWnd; // ins
public:
BOOL InitInstance()
{
// del wnd = new MFC_Tutorial_Window();
// del m_pMainWnd = wnd;
m_pMainWnd = new MFC_Tutorial_Window(); // ins
m_pMainWnd->ShowWindow(1);
return 1;
}
};
MyApp theApp;
What's the matter?
The problem is in redeclaration of member variable MFC_Tutorial_Window *m_pMainWnd;
, without this row it'll work.