• MFC is Microsoft Foundation Class.

  • composed with combination of Win32 api and class (object-oriented)

  • MFC is almost depricated by many alternatives like .net WPF and other crossplatform GUI libraries

  • declare field HWnd inside header file to create child windows

    • you need to call Create() method of them to replace CreateWindow() of win32
  • since MFC works as OOP wrapper of win32, message dealing system how win32 do with CALLBACK function is replaced by MessageMap macro inside HWnd

  • SDI

    • CWinApp
    • CFrameWind
    • CView
    • CDocument
  • MDI

  • Dialog based

  • MessageMap

    • do work of CALLBACK funtion on MFC
    • composed with two macros (at top of source);
      • BEGIN_MESSAGE_MAP( CustumView, CView )
      • END_MESSAGE_MAP()
    • examples
      • OnCreate() : mapped with WM_CREATE (ON_WM_CREATE())
      • OnSize() : mapped with WM_SIZE (ON_WM_SIZE())
      • OnPaint() : mapped with WM_PAINT (ON_WM_PAINT())
      • OnClose() : mapped with WM_CLOSE (ON_WM_CLOSE())
      • ON_COMMAND( CHILD_ID, OnCustumFunction )
        • this is macro inside message map
        • unlike default mapping like ON_WM_CREATE(), this macro has two parameters
          • CHILD_ID : UINT value (normally defined by macro)
          • OnCustumFunction : void (*) (void) type function
        • calls OnCustumFunction() when control with CHILD_ID occur WM_COMMAND message
    • message processing class

      almost messages occur in CView type object. so message will be sent in CView’s MessageMap.
      but if there’s no proper MessageMap in CView type object, it will be sent to CDocument type object’s MessageMap.
      if there’s no MessageMap, next is CFrameWnd.
      and next is CwinApp.
      CView -> CDocument -> CFrameWnd -> CWinApp

  • CWinApp

    • InitInstance() : called when mfc program started
    • Run() : loop function
    • ExitInstance() : called when mfc progran ended
  • AfxMessageBox()

    1
    
    void AfxMessageBox( _T("text") );
    
    • work as MessageBox of win32