Example

The following example shows how to register an application-supplied object to receive notification of operator keystroke events. See the ECLKeyNotify Class for a RegisterKeyEvent example.

// This is the declaration of your class derived from ECLKeyNotify....
class MyKeyNotify: public ECLKeyNotify
{
public:
  // App can put parms on constructors if needed
  MyKeyNotify();	 						  // Constructor
  MyKeyNotify();							  // Destructor
 
  // App must define the NotifyEvent method
  int NotifyEvent(char KeyType[2], char KeyString[7]);  // Keystroke callback
 
private:
  // Whatever you like...
};
// this is the implementation of app methods...
 
int MyKeyNotify::NotifyEvent( ECLPS *, char *KeyType, char *Keystring )
{
  if (...) {
    ...
    return 0;  // Remove keystroke (filter)
  }
  else
    ...
    return 1;  // Pass keystroke to emulator as usual
  }
}
 
// this would be the code in say, WinMain...
 
ECLPS	*pPS;					       // Pointer to ECLPS object
MyKeyNotify *MyKeyNotifyObject;	// My key notification object,derived
                                   // from ECLKeyNotify
 
try {
  pPS = new ECLPS('A');              // Create PS object for 'A' session
 
  // Register for keystroke events
  MyKeyNotifyObject = new MyKeyNotify();
  pPS->RegisterKeyEvent(MyKeyNotifyObject);
 
  // After this, MyKeyNotifyObject->NotifyEvent() will be called
  // for each operator keystroke...
}
catch (ECLErr HE) {
  // Just report the error text in a message box
  MessageBox( NULL, HE.GetMsgText(), "Error!", MB_OK );
}