Advertisement

C++类成员函数作为回调函数

阅读量:

遇见

在实际开发过程中,当调用第三方SDK、跨框架层的事件通知机制或外部C语言库时,通常需要借助对应的接口注册回调函数以应对特定事件。本文将以NOLO SDK为例,对这一类问题进行具体说明。

复制代码
    typedef enum ExpandMsgType {
    
      DoubleClickMenu=1,
      DoubleClickSystem
    }ExpandMsgType;
    
    typedef void(__cdecl *expandMsg_FuncCallBack)(ExpandMsgType expandMsgType);
    NOLO_API  bool _cdecl expandDataNotify_FuncCallBack(expandMsg_FuncCallBack fun);
    

我们定义一个expandMsg_FuncCallBack类型的回调函数,具体实现代码如下:

复制代码
    #include "stdafx.h"
    #include <windows.h>
    #include "nolo_api.h"
    using namespace NOLO;
    class HeadMountDevice{
    public:
    HeadMountD

全部评论 (0)

还没有任何评论哟~