How can I get class name of a document in my program. I mean, I have done this:
pDocTemplate = new CMultiDocTemplate(
IDR_FRAMETYPE,
RUNTIME_CLASS(CFrameDoc2D),
RUNTIME_CLASS(CEditorChildFrame),
RUNTIME_CLASS(CFrameView));
gl_pDocTemplateManager->AddTemplateInfo("CMyDoc", eStructure);
AddDocTemplate(pDocTemplate);
I want to get CMyDoc
string in another project (.dll) of my MSVC solution via CDocument
class. I can't cast to a specific document class due to cyclic dependencies.
I'm not sure what AddTemplateInfo()
does, it does not seem to be a standard MFC function.
To get the name of the class, you could use something like:
CRuntimeClass *pClass = pDoc->GetRuntimeClass();
if (pClass != NULL)
TRACE(_T("Document class = %S\n"), pClass->m_lpszClassName);
NOTE: m_lpszClassName
is ASCII (LPCSTR
) and the code above assumes your project is based on Unicode -- otherwise, change %S
to %s
.