The EnableEvents method assigns or replaces the
callback function that receives browser events for the specified host
window. It can be used after the browser has been attached to start
receiving notifications or to change event handlers at runtime. The
change takes effect immediately and subsequent events will be invoked
using the new handler.
Event delivery is serialized by the library and this call safely
updates the event handler. You cannot specify a NULL pointer as the
event handler; if you need to disable events, use the
DisableEvents method. If events were previously frozen
with FreezeEvents, calling this method with a new event
handler will automatically unfreeze event notifications.
When using this method from within a C++ class, the event
callback must be declared as a static function with the __stdcall
(or CALLBACK) calling convention. This is required because
the library calls the handler just as it would with any Win32 API
callback function, without knowledge of C++ instance objects. Non-static
member functions include a hidden this pointer parameter,
which makes their signature incompatible with the expected
WEBVIEWEVENTPROC type. A common pattern is to pass the
object's this pointer as the dwParam value, then cast it
back inside the static callback function to access the instance. This
preserves object-oriented design while still meeting the calling
convention requirements of the API.