• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            MFC多文檔MDI_"打開文件"默認后綴名修改,根據需要添加

            參考:http://blog.csdn.net/segen_jaa/article/details/8489917

            應用背景:

            我用的是MDI框架,需要調用同事給的dll,才能確定本程序解析何種格式的文件。如他給了dll1,dll2,dll3,dll4,后綴分別是.format1,.format2,.format3,.format4。以后還可能會有(dll5,format5),(dll6,format6)

            因此在MDI加載文檔模板之前就要獲得全部后綴名,然后動態的傳給MDI。

            首先,需要修改打開文件的后綴名。需要重載CMultiDocTemplate,參考文章的后綴也是在主程序中寫好的,不是我想要的,

            很簡單,在繼承類中多加一個參數 char *suffix,

            具體實現如下:

            [cpp] view plain copy

            1. #pragma once
            2. #include "afxwin.h"
            3. class CMultiDocTemplateSuffixEx :   public CMultiDocTemplate  
            4. {  
            5.     CString m_strSuffix;  
            6. public:  
            7.     CMultiDocTemplateSuffixEx(char *suffix,UINT nIDResource, CRuntimeClass* pDocClass,  
            8.         CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass):\  
            9.         CMultiDocTemplate( nIDResource, pDocClass, pFrameClass, pViewClass )  
            10.     {  
            11.         m_strSuffix.Format("%s",suffix);  
            12.     }  
            13. virtual BOOL GetDocString(CString& rString, enum DocStringIndex index) const
            14.     {  
            15. if(index == CDocTemplate::filterExt)  
            16.         {  
            17.             rString = "."+m_strSuffix;  
            18.         }  
            19. else if( index == CDocTemplate::fileNewName || index == CDocTemplate::filterName )  
            20.         {  
            21.             rString = m_strSuffix+"(*."+m_strSuffix+")";        }  
            22. else
            23.         {  
            24.             __super::GetDocString(rString,index);  
            25.         }  
            26. return TRUE;  
            27.     };  
            28. }; 

            使用:

            [cpp] view plain copy

            1. CMultiDocTemplate *pDocTemplate0;  
            2. char *curSuffix[]={"format1","format2","format3"};  
            3. for(int i=0; i<3; i++)  
            4.     {  
            5.         pDocTemplate0 = new CMultiDocTemplateSuffixEx  
            6.             (curSuffix[i],IDR_MAINFRAME,  
            7.             RUNTIME_CLASS(CTestDoc),  
            8.             RUNTIME_CLASS(CChildFrm),  
            9.             RUNTIME_CLASS(CTestView));  
            10.         AddDocTemplate(pDocTemplate0);  
            11.     }  

            posted on 2017-02-13 13:03 FongLuo 閱讀(946) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            <2017年2月>
            2930311234
            567891011
            12131415161718
            19202122232425
            2627281234
            567891011

            導航

            常用鏈接

            留言簿

            隨筆分類(11)

            隨筆檔案(79)

            文章檔案(1)

            收藏夾(38)

            學習網站

            一般網站

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久亚洲春色中文字幕久久久| 国产精品久久久久无码av| 久久中文字幕无码专区| 色狠狠久久综合网| 狠狠狠色丁香婷婷综合久久俺| 99久久精品九九亚洲精品| 久久久SS麻豆欧美国产日韩| 成人免费网站久久久| 久久91精品国产91| 国产精品嫩草影院久久| 久久久无码人妻精品无码| 亚洲精品国产第一综合99久久| 97精品久久天干天天天按摩| 中文精品99久久国产| 久久精品国产一区二区三区不卡| 人妻丰满AV无码久久不卡| 久久无码AV中文出轨人妻| 2020最新久久久视精品爱| 久久精品99久久香蕉国产色戒| 亚洲日本va午夜中文字幕久久 | 久久96国产精品久久久| 7777久久久国产精品消防器材| 久久综合九色欧美综合狠狠| 久久青青草原综合伊人| 狠狠色丁香久久综合五月| 久久久久人妻一区精品性色av| 久久久久免费精品国产| 久久人人爽人人爽人人片AV东京热| 国产99久久九九精品无码| 9191精品国产免费久久| 亚洲精品国产成人99久久| 亚洲狠狠综合久久| 精品视频久久久久| 久久精品国产亚洲Aⅴ香蕉| 久久久久亚洲av毛片大| 久久久久国产成人精品亚洲午夜| 久久久久夜夜夜精品国产| 国产一区二区精品久久岳| 精品国产一区二区三区久久蜜臀| 国产成人精品久久综合| 久久乐国产精品亚洲综合|