CWebView::Detach Method  
 
BOOL Detach();

The Detach method releases the resources allocated for the browser session.

Parameters

None.

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 is used to detach the browser instance from a window that it was previously attached to using either the Attach method. It is automatically called by the class destructor when the browser is no longer needed and the host window is being destroyed. If the browser was created using the Create method, calling this method has the same effect as calling the Close method.

This method will cause the WEBVIEW_EVENT_WINDOW_DETACHED event to fire as part of the normal process of detaching from the window. If you implement a handler for this event, you should never delay this process by attempting to show a dialog or request input from the user (for example, by displaying a message box). At the point this event is fired, the browser objects have already been disposed and there is no way to prevent the process from completing.

If there is a navigation in progress at the time this method is called, it will be canceled. If there are one or more file downloads in progress, the transfers will be aborted.

The current thread will block while it waits for the WebView2 browser process to shutdown gracefully. If the browser becomes non-responsive, this method will wait several seconds before forcibly terminating the child process and continuing with the cleanup process. If a temporary user profile was specified or a private browsing session was created, this method will also clear the browser cache and remove the user data folder that was created for the session.

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