革命被扼杀在摇篮中,信心大减,程序还没开始运行就崩溃,什么断言失败,不懂?该如何处理

革命被扼杀在摇篮中,信心大减,程序还没开始运行就崩溃,什么断言失败,不懂?
-------------
Sample01.h
class CSample01App:public CWinApp
{
public :
virtual BOOL InitInstance();

};

class CSample01Frame:public CFrameWnd
{
public :
CSampele01Frame();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};

---------------------
Sample01.cpp
#include<afxwin.h>
#include"Sample01.h"

CSample01App theApp;
BOOL CSample01App::InitInstance()
{
m_pMainWnd=new CSample01Frame();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP(CSample01Frame,CFrameWnd)
  ON_WM_PAINT()
END_MESSAGE_MAP()

CSample01Frame::CSampele01Frame()
{
Create(NULL,"MFC应用程序框架");
}

void CSample01Frame::OnPaint ()
{
CPaintDC dc(this);
dc.TextOut(100,100,"Hello World!");
}

------解决方案--------------------
m_pMainWnd- >ShowWindow(m_nCmdShow); 

在这之前要创建窗体, 构造函数应该没创建成功
Create(NULL,"MFC应用程序框架"); 

------解决方案--------------------
先Create 
m_pMainWnd
------解决方案--------------------
CWnd( );
Constructs a CWnd object.

The Windows window is not created and attached until the CreateEx or Create member function is called.
也就是说,调用CWnd()并不能真正的创建对话框。

Returns m_hWnd, or NULL if the this pointer is NULL.
HWND GetSafeHwnd( ) const;
Return Value
Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer. 
这个是对m_hWnd的解释。
也就是说如果没有调用CreateEx,那么m_hWnd始终是NULL,所以没有办法使用。

 
m_pMainWnd=new CSample01Frame();
m_pMainWnd->Create(NULL,"MFC应用程序框架");
m_pMainWnd- >ShowWindow(m_nCmdShow);
m_pMainWnd- >UpdateWindow();
------解决方案--------------------
Create的解释:
You construct a child window in two steps. First, call the constructor, which constructs the CWnd object. Then call Create, which creates the Windows child window and attaches it to CWnd. Create initializes the window's class name and window name and registers values for its style, parent,
and ID.

也就是说必须是先调用了constructor,而LZ的Create(NULL,"MFC应用程序框架")方法就在constructor中,这种
逻辑肯定是错了。
------解决方案--------------------
m_pMainWnd- >Create(NULL,"zhangyanli",WS_OVERLAPPEDWINDOW,CRect(0,0,100,200),NULL,0); 

------解决方案--------------------
LZ如果知道是家伙在捣鬼................
class CSample01Frame:public CFrameWnd
{
public :
CSampele01Frame();//注意这里啊,仔细看
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
------解决方案--------------------
首先:使用这种方法只能创建子窗口,也就是说必须要有父窗口的情况下才能创建,而在m_pMainWnd没有创建的情况下,父窗口不存在,所以没有办法这样处理。

至于在其他的情况下,为什么就可以这样来创建,我想主要是因为其中都已经有了父窗口吧。

这只是我的意见,需要高手解决。
------解决方案--------------------
m_pMainWnd= new CSample01Frame; 
((CSample01Frame*)m_pMainWnd)->Create(NULL, "MFC应用程序框架");
m_pMainWnd->ShowWindow(m_nCmdShow); 
m_pMainWnd->UpdateWindow(); 
return TRUE; 

不要在构造函数中调用Create