본문 바로가기

Programming/MFC

CMainFrame 전역 객체

헤더에 선언


class CMainFram ...

{

}


// MainFrame 포인터에 대한 접근을 허용
extern CMainFrame* g_pMainFrame;





cpp에 선언


// 전체프로그램에서 사용되는 전역변수
CMainFrame* g_pMainFrame;




생성자에 선언


g_pMainFrame = this ;



이후에 헤더파일 인클루드 하여 전연 변수로 사용하면 된다.