• <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_"打開文件"默認后綴名修改,根據(jù)需要添加

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

            應(yīng)用背景:

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

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

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

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

            具體實現(xiàn)如下:

            [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 閱讀(932) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            <2008年4月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            導(dǎo)航

            常用鏈接

            留言簿

            隨筆分類(11)

            隨筆檔案(79)

            文章檔案(1)

            收藏夾(38)

            學習網(wǎng)站

            一般網(wǎng)站

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            99久久精品毛片免费播放| 久久99国产精品久久99果冻传媒 | 午夜欧美精品久久久久久久| 尹人香蕉久久99天天拍| 99久久精品免费看国产一区二区三区 | 亚洲综合精品香蕉久久网| 国产精品无码久久综合 | 人妻精品久久久久中文字幕69 | 久久亚洲精品无码VA大香大香| 亚洲国产精品无码久久一线| 国产A级毛片久久久精品毛片| 久久综合鬼色88久久精品综合自在自线噜噜| 亚洲国产精品无码久久久不卡 | 综合网日日天干夜夜久久| 天天综合久久久网| 久久久久亚洲Av无码专| 亚洲精品成人网久久久久久| 情人伊人久久综合亚洲| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 久久亚洲精品视频| 乱亲女H秽乱长久久久| 三级三级久久三级久久| 久久国产精品免费| 久久99国产精品久久久| 亚洲AV日韩精品久久久久 | 久久久久久夜精品精品免费啦| 久久精品中文字幕一区| 99久久免费国产精精品| 国产综合久久久久久鬼色| 久久综合狠狠综合久久| 亚洲精品蜜桃久久久久久| 久久精品卫校国产小美女| 奇米影视7777久久精品人人爽| 亚洲а∨天堂久久精品| 久久天天躁狠狠躁夜夜2020老熟妇 | 中文字幕亚洲综合久久| 国产99精品久久| www亚洲欲色成人久久精品| 欧美一区二区精品久久| 狠狠精品干练久久久无码中文字幕 | 久久国产成人精品麻豆|