我有一个CFormView
- 派生类,它有一个我试图调用的按钮ShowWindow
。但是,此调用失败,因为m_hWnd
变量为空。为什么 m_hWnd 为空?该对话框child
在属性窗口中设置了样式,并且我将父级CFrameWnd
与表单视图相关联。此视图旨在实现无模式。
创建视图的代码:
void CMainFrame::SwitchEditView(CRuntimeClass * pViewClass)
{
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=this;
m_subSplitter.CreateView(0,1,pViewClass,CSize(0,0), &context); // create new view and add it to the splitter window
}
我的 CFormView 派生类的构造函数:
CDFAManEditViewProject::CDFAManEditViewProject()
: CFormView(CDFAManEditViewProject::IDD)
{
// c_btnEdit is a CButton MFC control
c_btnEdit.ShowWindow(SW_SHOW); // this call fails on ASSERT(::IsWindow(m_hWnd) )
}