回调函数

被调用方:

h:
static void __stdcall ShowInfoCallback(void * a_pOwner, tagPatientInfoStruct a_PatientInfo); //浏览信息
void ShowInfo(tagPatientInfoStruct a_PatientInfo);

CPP:
void __stdcall CPatientDlg::ShowInfoCallback(void * a_pOwner, tagPatientInfoStruct a_PatientInfo)
{
CPatientDlg * pMe = (CPatientDlg*)a_pOwner;
pMe->ShowInfo(a_PatientInfo);
}

void CPatientDlg::ShowInfo(tagPatientInfoStruct a_PatientInfo)
{

}

调用方:

h:
typedef void (__stdcall * ShowInfoCallback)(void * a_pOwner, tagPatientInfoStruct a_PatientInfo);

ShowInfoCallback m_FuncShowInfo;
void * m_pFuncShowInfoOwner;

void RegisterShowInfo(void * a_pOwner,ShowInfoCallback a_FuncShowInfo)
{
m_pFuncShowInfoOwner = a_pOwner;
m_FuncShowInfo = a_FuncShowInfo;
}
void FuncShowInfo(CPatientInfoStruct patientInfo)
{
m_FuncShowInfo(m_pFuncShowInfoOwner, patientInfo);
}

原文地址:https://www.cnblogs.com/waterair/p/6738908.html