Cannot Use MFC in UE4 Project

There is a project written by VC++. I need to add it to my UE4 project.

Because VC++’s macros and variables are used in the VC++ project. So I included “afxwin.h” “afxcmn.h” two header files in the UE4 project. when I Compile the UE4 project then have the error.

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE\afx.h(24): fatal error C1189: #error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

If my UE4 project is a MFC project,that can easy to solve this problem. Like this set Use MFC in a shared Dll. or
C/C++ ->Code Generation ->Runtim Libray change to Multi-threaded(/MTd)

How to solve this error in UE4 project.

Or how to change this MFC code into UE4 code.

In .h
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LRESULT OnSIPCallbackEvent(WPARAM WParam, LPARAM LParam);
DECLARE_MESSAGE_MAP()

In .Cpp
BEGIN_MESSAGE_MAP(CSIPSampleDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_MESSAGE(WM_SIPEVENT, OnSIPCallbackEvent)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()