一个Wizard生成多文档MFC应用,如下
BOOL CMyApp::InitInstance()
{
.....
// 创建主 MDI 框架窗口
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
.....
pMainFrame->DoSomething(); return TRUE;
}int CMainFrame::DoSomething()
{
m_dlgBar.DoSomething(); // CDialogBar m_dlgBar return 0;
}int CDialogBar::DoSomething()
{ m_ComboBox.reset();
return 0;
}ComboBox:: DoSomething()
{
ResetContent(); //出错
}在CDialogBar上放个按钮,执行m_ComboBox.ResetContent(); 一切正常,而通过CMyApp的initInstance()调用Dosometing()则出错,提示在AfxWin2.inl出错,通过debug看CDialogBar的hWnd = 00000000
这是为什么?正常情况下hWnd应该为0么?
BOOL CMyApp::InitInstance()
{
.....
// 创建主 MDI 框架窗口
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
.....
pMainFrame->DoSomething(); return TRUE;
}int CMainFrame::DoSomething()
{
m_dlgBar.DoSomething(); // CDialogBar m_dlgBar return 0;
}int CDialogBar::DoSomething()
{ m_ComboBox.reset();
return 0;
}ComboBox:: DoSomething()
{
ResetContent(); //出错
}在CDialogBar上放个按钮,执行m_ComboBox.ResetContent(); 一切正常,而通过CMyApp的initInstance()调用Dosometing()则出错,提示在AfxWin2.inl出错,通过debug看CDialogBar的hWnd = 00000000
这是为什么?正常情况下hWnd应该为0么?
最后一个函数写错了
应该是
ComboBox:: Reset()
{
ResetContent(); //出错
}请各位大虾指教
我该在什么事件调用?
该在mainFrame的OnCreate函数时调用
void CMyApp::OnAppAbout()
{
CMainFrame *pMainFrame = (CMainFrame*) AfxGetMainWnd();
pMainFrame->DoSomething();
//CAboutDlg aboutDlg;
//aboutDlg.DoModal();
}
还是在那个地方出错
应该是调用的问题
因为此时,整个应用的初始化都完成了,我用帮助菜单下的关于来调用还是不行
{ // 该处设断点,执行后,debug提示如下
ResetContent(); //出错
}在debug中,
this cxx0069:error: variable needs stack frame
是什么意思?
谢谢各位帮忙
虽然debug也提示
在debug中,
this cxx0069:error: variable needs stack frame
但一切都可以执行,而且没有任何弹出错误