版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、mfc如何在文檔(cxxxdoc)類或框架(cmainframe)類中獲得視類(cmyviewHow does MFC get a visual class in the document (cxxxdoc) class or CMainFrame class (cmyview)How does MFC get a visual class in the document (CXXXDoc) class or CMainFrame class (CMyView.txt)How does MFC get the view class (CMyView) pointer in the docume
2、nt (CXXXDoc) class or the framework (CMainFrame) class?In the document class, just use the (multi document, single document, a little simpler)POSITION (pos=this->GetFirstViewPosition); / / to write in the document class, to replace this document pointer can be in other classesWhile (POS)CView *pV
3、iew=this->GetNextView (POS);In the framework class, just select the document object, and then use the code aboveHere's an aspect of getting another object from an object (excerpt from MFC)The method of obtaining another object from an objectThe member functions used by the object to be obtain
4、ed by this objectCDocument object view list GetFirstViewPosition, GetNextViewDocument template GetDocTemplateCView object document object GetDocumentBorder window GetParentFrameCMDIChildWnd orCFrameWnd object activity view GetActiveViewActive visual document GetActiveDocumentCMDIFrameWnd object, act
5、ive document, border window, MDIGetActiveUse GetActiveView () in the framework class;In the document class (CMainFrame*) (AfxGetApp () ->m_pMainWnd) ->GetActiveView ();How does MFC get the pointer to the View class under CMainFrame?Using the GetActiveView () functionHow do ordinary classes in
6、MFC get pointers to the view class?How do I get pointers to the view class in the class (Generic)? I've tried that:CMainFrame *p= (CMainFrame*) AfxGetMainWnd ();CView, *pv=p->GetActiveView ();According to your usage, that's all right!Is this the View that hasn't been created yet, so P
7、V is empty?.CMainFrame *m_pfm = (CMainFrame*) AfxGetApp () ->m_pMainWnd;. *m_pView = (*) m_pfm->GetActiveView ();One less word: AfxGetApp ()CMainFrame *p= (CMainFrame*) AfxGetApp () ->m_pMainWnd;CView *pv = (CView*) p->GetActiveView ();Upstairs in charge of building analysis, a sequence
8、of function calls, not what is PreCreateWindow or CXXXApp, the constructor of the CXXXFrame InitInstance, the main window template did not finish for the manipulation of the CView.AsdfasdfHow do I return a pointer to a class in MFC, such as CWIN, view, and so on!In the CView class, call this->Get
9、Document () to get doc.In the CDocument class, call GetFirstViewPosition () and GetNextView () to get all the view.In other classes, one method is to pass the pointer in for the call to use.Also, you get CWinApp with AfxGetApp (), then GetFirstDocTemplatePosition () and GetNextDocTemplate () to get
10、the doc template, and then call GetFirstDocPosition () and GetNextDoc () to get the doc.How do I get the pointer of the View class (this) or the pointer of the whole dialog box in the OnDraw function or the *Dlg function?In a single document, you can use the following methods:The file where you want
11、 to get the pointer now contains two files at the start:View of the main frame class header file, that is, #include "MainFrm.h""View class header file, that is, #include "XXView.h""Then add the following statement at the point where you want to access the m_pSetCMainFra
12、me* frm= (CMainFrame*) AfxGetApp () ->m_pMainWnd;CXXView* pView= (CXXView*) frm->GetActiveView ();PView, that is, the View class pointerBut isn't it easier for you to use this?In the single document of MFC, the view window handle produced by Ctestview is obtained from the treeview class of
13、 a viewGets the window handle of the view in the single document framework. Ask for a piece of code. Check online, did not get it out. Which brother has time to write a paragraph?.You're not clear. There are many ways to carry it out.You can get the view pointer through the global object theApp,
14、 and thenView pointer ->GetSafeHwnd (); gets the handle.You can also send custom messages to send the handle to the specified window class.You can also define a Cview pointer in your stdafx.h, which points to the View class during the initialization process, and is used in your treeview.You can a
15、lso receive a handle for the treeview class definition method by itself, when called.Note that you can handle the creation sequence, or else you will make an assertion error under debug.The method is really a lot.If you do not use the document / view structure, the single document is created in the
16、build frame window. There is a variable called m_wndView. This is the handle. He's a CWnd derivative.If you use the document / view structure, direct GetActiveView is fine.There is one more case, if you use the split window.Which function has been forgotten?. Get*Pane seems. Check it.How is the
17、initial title of the view window produced by the MFC single document Ctestview?You can modify the character file in the resource file, specifically how to modify the Internet search,Another method is to join return in the PreCreateWindow function of the view classM_strTitle = single document header&
18、quot;You started another thread, CMyApp. How do you access my View class in CMyApp?If I were to regenerate a WinApp class and call AfxBeginThread (RUNTIME_CLASS) CMyApp) to start another thread, then how do I access my View class in CMyApp?I asked the question in the morning, but no one gave me the
19、answer. A master can enlighten ah1. You can pass in the class of this View as a parameter, which is the easiest solution2.You can get it in the following wayCWinApp * pA=AfxGetApp ();POSITION, pos=pA->GetFirstDocTemplatePosition ();CDocTemplate * pDT=pA->GetNextDocTemplate (POS);Pos=pDT->Ge
20、tFirstDocPosition ();CDocument * pD=pDT->GetNextDoc (POS);Pos=pD->GetFirstViewPosition ();CView * pV=pD->GetNextView (POS);Of course, the principle is that if you have multiple View, or have Doc, or even multiple DocTemplate, you can adjust it appropriatelyThe source code, I tried, and shou
21、ld be no problemHow does the MFC single document get a handle to the window of the View view (the window produced by the CmyView class instance)? In another view classGet through the App classHeader file definition: CmyView, *GetmyView ();Realization:CmyView *CmyApp: GetmyView ()If (m_pDocManager)PO
22、SITION pos1 = m_pDocManager->GetFirstDocTemplatePosition ();While (pos1)CDocTemplate *pDocTemplate = m_pDocManager->GetNextDocTemplate (pos1);If (pDocTemplate)POSITION pos2 = pDocTemplate->GetFirstDocPosition ();While (pos2)CDocument *pDoc = pDocTemplate->GetNextDoc (pos2);If (pDoc)POSITION pos3 = pDoc->GetFirstViewPosition ();While (pos3)CView *pView = pDoc->GetNextView (pos3);If (pView)If (pView->IsKindOf (RUNTIME_CLASS (CmyView)Return (CmyView*) pVi
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 吸引小學生的英語課件
- 法制培訓課件名稱
- 生產(chǎn)安全宣講課件
- 小學生美術課件制作視頻
- 消防教學培訓課件
- 七年級科學上冊9.2家庭用電9.2.4家庭用電的安全措施學案無答案牛津上海版
- 三年級數(shù)學上冊第3單元圖形的運動一3.4有趣的剪紙課時練冀教版
- 三年級科學上冊第二單元我們怎么知道第七課它是什么教案青島版
- 道路安全生產(chǎn)課件講義
- 上半年大一學生會工作參考計劃范文
- GB/T 8571-2008復混肥料實驗室樣品制備
- GB/T 3216-2016回轉(zhuǎn)動力泵水力性能驗收試驗1級、2級和3級
- 期末家長會(小學生一年級期末家長會課件)
- 【高教版周紹敏】 電工技術基礎與技能教案
- 【醫(yī)療】急診預檢分診專家共識課件
- 國家開放大學《西方經(jīng)濟學》復習題庫及參考答案
- 北京版小學三年級數(shù)學下冊全套課件
- 中國近代史綱要(完整版)
- 修井緊急情況的處理措施應急方案
- 智能座艙市場與技術發(fā)展趨勢研究白皮書課件
- 中級無機化學答案版
評論
0/150
提交評論