Lyle,
Yes you are right in that the OnVisaEventHandler macro is used if you want to install a member function of a class as a handler for a VISA event and this class also contains the CNiVisaSession object for which you are installing the event handler.
For example, if you have the following class definition,
class MyClass {
public:
void Init ();
ViStatus OnEvent (CNiVisaEvent& event);
private:
CNiVisaSession session;
};
and you want to install the OnEvent function as the handler for the VISA event of the CNiVisaSession object (session), you must use the OnVisaEventHandler macro as shown below.
MyClass::Init () {
session.InstallEventHandler(VisaEventTrigger, *this, OnVisaEventHandler(MyClass, OnEvent));
}
Failure to use this macro results in the following compiler error:
error C2661: 'InstallEventHandler' : no overloaded function takes 2 parameters
Note that you do not need to use this macro if you are installing a member function of an external class as the event handler.
For example, if you have the following class definition,
class ExternalClass {
public:
ViStatus OnEvent (CNiVisaEvent& event);
};
then, you can install ExternalClass::OnEvent in as MyClass::Init the event handler as shown below.
MyClass::Init () {
ExternalClass e;
session.InstallEventHandler(VisaEventTrigger, e, ExternalClass::OnEvent);
}
Good luck with your application,
Azucena
National Instruments