C/C++/MFC
MFC 클래스간 통신
2006.05.25 17:57
SDI 형태
1. MainFrame 얻기
- CMainFrame *pFrame = (CmainFrame *) AfxGetMainWnd();
2. App 포인터 얻기
- CTestApp *pApp = (CtestApp *) AfxGetApp();
3. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestDoc *pDoc = (CTestDoc *)pFrame->GetActiveDocument();
- CTestDoc *pDoc = (CTestDoc *)((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();
4. View 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestView *pView = (CTestView *)pFrame->GetActiveView();
- CTestView *pView = (CTestView *) ((CMainFrame *)AfxGetMainWnd())->GetActiveView();
MDI 형태
1. ChildFrame 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
- CChildFrame *pChild = ((CMainFrame *)AfxGetMainWnd())->GetActiveFrame();
2. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CDsp240Doc *pDoc = (CDsp240Doc *)pChild->GetActiveDocument();
CDsp240Doc *pDoc = ( CDsp240Doc *)(((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveDocument();
3. View 포인터 얻기
- CCainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CMdiTestView *pView = (CMdiTestDoc *)pChild->GetActiveView();
- CMdiTestView *pView = ( CMdiTestView *)(((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveView();
주의 사항
위의 방법으로 포인터를 얻을 때는 해당되는 파일을 include 할때 순서의 주의해야 한다.
#include "MainFrm.h" // 1. Mainfrm
#include "Dsp240Doc.h" // 2. Doc
#include "Dsp240View.h" // 3. View
위의 방법으로 포인터를 얻을 때는 해당되는 파일을 include 할때 순서의 주의해야 한다.
#include "MainFrm.h" // 1. Mainfrm
#include "Dsp240Doc.h" // 2. Doc
#include "Dsp240View.h" // 3. View
.
관련 문서가 검색되었습니다.
- [2015/03/15] 블루투스로 스텝모터 제어 (4821)
- [2015/03/15] 시리얼 포트로 스텝모터 제어 (3319)
- [2014/11/28] 컴퓨터-아두이노 간의 블루투스 통신 (채팅) (4807)
- [2013/10/30] ZEO-S, CDS로 빛 밝기 -> LED ON/OFF (8920)
- [2013/09/02] ZEO-S PWM 펄스를 Pulse Counter로 읽기, C# (6785)
- [2013/08/29] ZEO-S, Pulse Counter, C# (6380)
- [2013/06/13] ZEO-S, 스위치로 LED ON/OFF, C# (10121)
- [2013/06/08] ZEO-S, LED 연속으로 이동, C# (8860)
- [2013/06/06] ZEO-S, LED 이동 속도 조절, C# (8749)
- [2012/06/06] C#, Form 속에 Form 넣기 (MDI형태) (26559)