來源:互聯(lián)網(wǎng)
發(fā)表時間:2017/1/12 11:24:06
責任編輯:魯曉倩
字體:
為了幫助網(wǎng)友解決“MFC,CEdit派生類與CreateView函數(shù)”相關(guān)的問題,學網(wǎng)通過互聯(lián)網(wǎng)對“MFC,CEdit派生類與CreateView函數(shù)”相關(guān)的解決方案進行了整理,用戶詳細問題包括:RT,我想知道:MFC,CEdit派生類與CreateView函數(shù),具體解決方案如下:
解決方案1:
這兩天在試驗CSplitterWnd類分割視圖的問題,目前是這樣一種情況,創(chuàng)建了CListView,CFormView,CEdit三個類的派生類,派生類分別為:CDictList,CDictPre,CDictInput,在MainFrm.h中定義了:CSplitterWnd m_wndSplitter1;重載了MainFrm的OnCreateClient函數(shù),代碼如下:BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext){// TODO: Add your specialized code here and/or call the base classif(!m_wndSplitter1.CreateStatic(this,1,2)){return FALSE;}//請注意下面這行代碼m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CDictInput),CSize(150,200),pContext);//9行m_wndSplitter1.CreateView(0,1,RUNTIME_CLASS(CDictPre),CSize(200,200),pContext);return TRUE;//return CFrameWnd::OnCreateClient(lpcs, pContext);}現(xiàn)在的問題是,如果我在CreateView函數(shù)中,使用RUNTIME_CLASS(CDictList)、RUNTIME_CLASS(CDictPre)則能編譯運行,如將CDictInput(派生于CEdit)中,編譯則會報錯,錯誤信息為:D:\C++code\MyDict\MainFrm.cpp(120) : error C2039: 'classCDictInput' : is not a member of 'CDictInput'd:\c++code\mydict\dictinput.h(15) : see declaration of 'CDictInput'D:\C++code\MyDict\MainFrm.cpp(120) : error C2065: 'classCDictInput' : undeclared identifier請大家?guī)兔纯戳?!分少了點,滿意可追加哦!
解決方案2:
classCDictInput 這個似乎是連寫導致的報錯吧。class CDictInput中間有個空格。CDictInput沒有定義,是因為你沒有將定義它的頭文件包含到使用它的cpp文件中。有問題可以hi我,這個很簡單的問題。你選的時候選擇CEditView作為基類吧,CEdit類可能不行。你把那個類刪除掉,然后從CEditView派生一個視圖類??赡苁沁@樣的,CreateView只能生成CView及其派生類的視圖,其它類是不可以的。
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。