c++ - Parent Window is NULL in CFormView (MFC) -
i have cformview
-derived class has button trying call showwindow
on. however, call fails because m_hwnd
variable null. why m_hwnd null? dialog has child
style set in properties window, , i'm associating parent cframewnd
form view. view intended modeless.
code creates view:
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 , add splitter window }
the constructor cformview-derived class:
cdfamaneditviewproject::cdfamaneditviewproject() : cformview(cdfamaneditviewproject::idd) { // c_btnedit cbutton mfc control c_btnedit.showwindow(sw_show); // call fails on assert(::iswindow(m_hwnd) ) }
you trying access edit control view constructor. view window has not been created yet when constructor runs. why have no m_hwnd , no edit control yet.
move initialization of controls view's oninitialupdate.
Comments
Post a Comment