[MFC] MFC execution flow (initialize~ finalize)

2019. 7. 29. 23:22Development/C++

MFC Dialog Initialize to Finalize

mfc execution flow!

start application -> end application

 

CTempApp::CTempApp() ------ Since the App class variable is declared as a global variable, the constructor is called first
CTempApp::InitInstance() ------ Called from AfxWinMain function hidden in MFC code. (Responsible for loading program setting information, parameter processing, etc.)
CTempDoc::CTempDoc (void) ------ InitInstance() first creates a Document object
CMainFrame::CMainFrame (void)
CMainFrame::LoadFrame() ------ Windows are created
CMainFrame::PreCreateWindow()
CMainFrame::PreCreateWindow()
CMainFrame::OnCreate() ------ Called when a CMainFrame object is created and a window is created and a WM_CREATE message is generated automatically
    CMainFrame::OnCreateClient()
        CTempView::CTempView() ------ OnCreateClient() creates a View object
        CTempView::Create()
        CTempView::PreCreateWindow()
        CTempView::OnCreate()
        CTempView::OnShowWindow() ------ Proceed so far to create a client view and display it on the screen.
    CMainFrame::OnCreateClient() - Return
CMainFrame::OnCreate() - Return ------ This completes the final creation of the window
CTempDoc::OnNewDocument() ------ Create a new document
CTempView::OnInitialUpdate() ------ If you create a new document or open an existing document, call this function to display the screen clean and appropriate content
CMainFrame::OnActivateApp()
CMainFrame::OnActivate() ------ The top-level window of the application is displayed and activated on the screen
CMainFrame::OnShowWindow()
CTempView::GetDocument()
CTempApp::Run() ------ Message looping

-------------------------------------------------- ---------------------------------- So far you have initialized the executable

    CMainFrame::OnClose() ------ Called by WM_CLOSE message when window is closed
        CMainFrame::OnShowWindow()
        CMainFrame::OnActivate()
        CMainFrame::OnActivateApp()
        CMainFrame::DestroyWindow() ------ Called by OnClose()
        CMainFrame::OnDestroy()
        CTempView::OnDestroy() ------ Mainframe WM_DESTROY message is also passed to the View object which is a child
        CTempView::PostNcDestroy()
        CTempView::~CTempView()
        CMainFrame::OnNcDestroy()
            CMainFrame::PostNcDestroy()
            CMainFrame::~CMainFrame()
        CMainFrame::OnNcDestroy() - Return
        CTempDoc::~CTempDoc() ------ When all windows are destroyed, the Document object is also destroyed.
    CMainFrame::OnClose() - Return
    CTempApp::ExitInstance()
CTempApp::Run() - Return