로그인

검색

API/MFC
2012.08.02 21:24

MFC 클래스간 통신

조회 수 14547 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄

http://whiteat.com/zbxe/?mid=WhiteAT_c&page=2&document_srl=3259


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


추가 사항

다이얼로그에서 모달창 또는 모달리스창을 띄운 후 메인 다이얼로그에 접근하려면

CxxxxxDlg* pMainDlg = (CxxxxxDlg*)AfxGetApp()->m_pMainWnd;

pMainDlg->someVariable 등의 형식으로 접근 가능


http://blog.naver.com/shin450279?Redirect=Log&logNo=40037253777

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 Tool/etc Programming 게시판 관련 2 MoA 2014.11.01 118396
34 LLM macOS에서 로컬 LLM 실험하기 OBG 2025.09.15 10175
33 Tool/etc SQLite Online - 11년간 1인이 개발, 하루 1.1만 명 사용 OBG 2025.10.15 9426
32 Tool/etc 원격 서버 개발용 편집기로 Helix 에디터를 활용하는 방법 OBG 2025.10.29 9384
31 LLM Claude Skills는 굉장하다, MCP보다 더 큰 혁신일지도 OBG 2025.10.29 9731
30 Tool/etc 오픈 노트북(Open Notebook): Google의 Notebook LM을 대체하는 오픈소스 플랫폼 OBG 2025.10.29 9447
29 LLM 로컬에서 오픈 LLM과 코딩 어시스턴트를 사용하시나요? 환경을 공유해주세요 OBG 2025.11.14 10149
28 Tool/etc LazyGit - 게으른 개발자를 위한 Git UI OBG 2025.11.14 9745
27 LLM 클로드 코드로 프로덕트 팀 바이브코딩 표준화한 방법 (aka 맥도날드 시스템) OBG 2025.11.24 8939
26 Web 함수형 프로그래밍을 배워보자! OBG 2025.11.25 7184
25 LLM HunyuanVideo-1.5 영상 생성 모델 OBG 2025.11.25 20037
24 Deeplearning Apriori 알고리즘 OBG 2025.12.09 7224
23 LLM A Guide to Claude Code 2.0 and getting better at using coding agents OBG 2026.01.05 16472
22 LLM 나노바나나 프로 레시피 북 OBG 2026.01.15 5231
21 Agent Claude Code 마스터하기 (Github, 책) OBG 2026.01.22 7075
20 Agent 앤트로픽 해커톤 우승자의 클로드 코드 구성(configuration) 전체 컬렉션 OBG 2026.01.22 3833
19 Agent Claude Code - Ollama Integration OBG 2026.01.26 7161
18 Agent Claude Skills 구축을 위한 완벽 가이드 OBG 2026.02.03 2771
17 Agent Claude Code 창시자가 공개한 실전 사용 팁 OBG 2026.02.03 2872
16 LLM everything is a ralph loop OBG 2026.03.05 2278
15 LLM [OpenAI] 엔지니어링 활용: 에이전트 우선 환경에서 Codex를 활용하기 OBG 2026.03.05 2437
Board Pagination Prev 1 ... 9 10 11 12 13 14 15 16 17 18 Next
/ 18