I have a C third-party library. In the header there is following function
bool bSetSelectMenuItemCallback(int( *pFunction )( int* piSelectedIndex, int iItemCount, int iTimeoutSec, const char* pcItemList, const char* pcFormHeader ) );
How to pass C++ function to this callback?
There is ActiveX(ocx) wrapper for this library, and inside it has following event
Event SelectMenuItem(string sFormHeader, long lTimeout, long lItemCount,
string sItemList, long plStatus, long plSelectedIndex)
We can see there is additional argument plStatus which is the result of the return of int( *pFunction ) as I understand. And you can easily subscribe to this event using something like
void Init() {
OcxLib ocx = new OcxLib()
ocx.SelectMenuItem += OnMenu();
}
void OnMenu(string sFormHeader, long lTimeout, long lItemCount,
string sItemList, long plStatus, long plSelectedIndex) {
Console.WriteLine("Inside event");
}
I want to do the same but in C++ directly(without using the ocx lib).