visual c++ - CDocTemplate and m_templateList -


i upgrading software 16 bit 32 bit in vc++ using mfc, , understand in recent versions of mfc can no longer access m_templatelist in cdoctemplate, must use getfirstdoctemplateposition , getnextdoctemplate instead. no problem far enumerating templates concerned (a dialog being opened in case there more 1 template). question approach best round fact reference template list being passed dialog on creation, , selected template being returned? here code:

void cmtapp::onfilenew() { cstring s;  if (m_templatelist.isempty())     {     trace0("error : no document templates registered cwinapp\n");     afxmessagebox(afx_idp_failed_to_create_doc);     return;     }  cdoctemplate* ptemplate = (cdoctemplate*)m_templatelist.gethead(); if (m_templatelist.getcount() > 1)     {     // more 1 document template choose     // bring dialog prompting user     copentypedlg dlg(&m_templatelist);     if (dlg.domodal() != idok)         return;     // none - cancel operation     ptemplate = dlg.m_pselectedtemplate;     ptemplate->getdocstring(s, cdoctemplate::docname);     }              assert(ptemplate != null); assert(ptemplate->iskindof(runtime_class(cdoctemplate)));  m_bnew = true; ptemplate->opendocumentfile(null); } 

you can pass cwinapp dialog's ctor , dialog can getfirstdoctemplateposition , getnextdoctemplate itself. don't need pass cwinapp because dialog can use afxgetapp itself.

if insist on passing template list build own list based on getfirstdoctemplateposition , getnextdoctemplate return.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -