Grabber::isListenerRegistered Method |
|||||||||||||||||
This method checks whether the specified callback handler is registered for the specified events. | |||||||||||||||||
Syntax: | bool isListenerRegistered( GrabberListener* pListener, DWORD callback = -1 ); |
||||||||||||||||
|
|||||||||||||||||
Return value: | true, if the callback handler is registered for at least one of the specified events. Otherwise, false is returned. |
||||||||||||||||
Sample: | This example shows how to register a callback handler that is derived from GrabberListener for a set of events. It shows also how to unregister the object for the events for which it was registered. Finally, it shows how to delete the callback handler object in a safe way. Grabber *grabber = new DShowLib::Grabber(); CListener *pcListener = new CListener(); // Create the GrabberListener object. // CListener is derived from // GrabberListener. // Register the pcListener object to the Grabber's GrabberListener objects list. grabber->addListener( pcListener, DShowLib::GrabberListener::eFRAMEREADY| DShowLib::GrabberListener::eOVERLAYCALLBACK ); grabber->startLive( true ); // Start the grabber // Events are handled now fflush(stdin); printf("Press [enter] to stop!"); getchar(); // The GrabberListener object must be unregistered for the events // for which it was registered, before it can be deleted. // First, unregister it for the frame ready event. grabber->removeListener(pcListener, DShowLib::GrabberListener::eFRAMEREADY); // Second, unregister it for the overlay callback event. grabber->removeListener(pcListener, DShowLib::GrabberListener::eOVERLAYCALLBACK); // Wait until all remove requests have been processed while( grabber->isListenerRegistered( pcListener, eALL) ) { Sleep( 0 ); // Wait } // Now, the application can be sure that the CListener methods // are no longer called by the Grabber. It is now safe to delete the // CListener object. delete pcListener; grabber->stopLive(); // Stop the grabber delete grabber; |
||||||||||||||||
See also: | Grabber, Grabber::addListener, Grabber::removeListener, Grabber::isListenerRegistered, GrabberListener, GrabberListener::tListenerType |