我在Doc/View构架应用程序中用下列语句为何无法显示窗体
class MyApp:public CWinApp
{
public:
BOOL InitInstance()
{
CDocument *doc;
CSingleDocTemplate *DocTemplate;
DocTemplate=new CSingleDocTemplate( //单文件样版类别
IDR_MENU1,
RUNTIME_CLASS(MyDocument),
RUNTIME_CLASS(MyFrame),
RUNTIME_CLASS(MyView));
AddDocTemplate(DocTemplate); //将文件样版加入应用程序
doc=DocTemplate->CreateNewDocument(); //建立新文件
m_pMainWnd=DocTemplate->CreateNewFrame(doc,NULL);
//建立新的视窗框架
DocTemplate->InitialUpdateFrame((CFrameWnd*)m_pMainWnd,doc);
//起始化View控件
m_pMainWnd->ShowWindow(SW_SHOW); //显示视窗
return true;
}
}a_app;
而换成以下语句就可以显示,
class MyApp:public CWinApp
{
public:
BOOL InitInstance()
{
CDocument *doc; //Declare指向文件的Point
CSingleDocTemplate *DocTemplate;
DocTemplate=new CSingleDocTemplate(
IDR_MENU1,
RUNTIME_CLASS(MyDocument),
RUNTIME_CLASS(MyFrame),
RUNTIME_CLASS(MyView));
AddDocTemplate(DocTemplate);//将SingleDocTemplate控件设给MyApp
doc=DocTemplate->CreateNewDocument(); //Create new file
m_pMainWnd=DocTemplate->CreateNewFrame(doc,NULL);
//Create 一个Window frame
DocTemplate->InitialUpdateFrame((CFrameWnd*)m_pMainWnd,doc);
//Initiative window frame控件,并Link View控件
m_pMainWnd->ShowWindow(SW_SHOW); //显示window
return true;
}
}a_app;
我找了很久没找出差别在哪,请问谁可以帮我找出第一段错在哪里!
没看出差别来
除了注释之外两段代码是一模一样的……
除了注释之外两段代码是一模一样的……