1.VC++的打开对话框中的文件类型可以有多种,这是怎么实现的。在哪里可以添加支持的文件类型。
2.还有怎么根据文件类型的不同,将内容正确显示出来。比如一种是.bmp,一种是.c。
同理保存的时候怎么来有选择的做串行化。谢谢你的帮助,如能提供相关资料更好!

解决方案 »

  1.   

    add multiple doctemplate to your application in CxxxApp::InitInstance()
     m_pEditDocTemplate = new CMultiDocTemplate(
    IDR_dcmviewerTYPE,
    RUNTIME_CLASS(CdcmviewerDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CEditView));
    AddDocTemplate(m_pEditDocTemplate);  m_pHistDocTemplate = new CMultiDocTemplate(
    IDR_dcmviewerTYPE,
    RUNTIME_CLASS(CdcmviewerDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(HistogramView));
    AddDocTemplate(m_pHistDocTemplate);
    CDocument* CxxxApp::OpenDocumentFile(LPCTSTR lpszFileName)
    {
    CDocument* pDoc = NULL;
    bool is_text_file = false;
    if(end_with(lpszFileName,_T(".txt"),true)|| end_with(lpszFileName,_T(".ini"),true)
    )
    {
    pDoc = m_pEditDocTemplate->OpenDocumentFile(lpszFileName);
    is_text_file = true;
    }
    else
            pDoc = m_pImageDocTemplate->OpenDocumentFile(lpszFileName);
            ...
    }