CWebView::FreezeEvents Method  
 
BOOL FreezeEvents(
  BOOL bFreezeEvents  
);

The EnableEvents method suspends or re-enables event notifications for the specified browser.

Parameters

bFreezeEvents
An integer value which specifies if event handling should be frozen. If the value is non-zero, browser events will be suspended until they are re-enabled. If the value is zero, browser events will be re-enabled if an event handler has been defined.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This method toggles a per-instance switch for event delivery. When events are frozen, the browser continues to operate normally and still generates events internally, but your application will not be notified of them. The events are not queued while frozen; they are discarded. For developers familiar with COM controls, this mirrors the behavior of IOleControl::FreezeEvents. When you unfreeze, only new events that occur after unfreezing will be delivered.

Event freezing can be useful when:

  • You are running scripted or programmatic operations that would otherwise flood your event handler, such as multiple page redirects or rapid AsyncExecute calls.
  • You are making a series of user interface changes and want to avoid reentrant updates. For example, temporarily stopping focus and/or size change events while moving or resizing controls.
  • You are showing a modal dialog or performing work where event reentrancy could complicate state management.
  • You need to suppress event-driven logic during controlled navigation, such as "silently" reloading a document or navigating to a new location.

Freezing does not alter browser state, navigation, or timers; it only affects your application's callback. To resume normal notifications, call this method with the bFreezeEvents parameter as zero. Freezing events will not affect calls to WaitForEvent. Because freezing events does not prevent browser events from occurring, they are still processed internally and you can wait for a specific event to complete.

If you discover that subsequent notifications within an event handler would interfere with your application's workflow, it is safe to freeze events from within the handler. After completing the operation, unfreeze events (for example, by posting an application-defined message or using a timer) so events resume normally. You should avoid calling DisableEvents from within an event handler, use freezing instead.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also