次の方法で共有


interface ICoreWebView2Settings9

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

interface ICoreWebView2Settings9
  : public ICoreWebView2Settings8

A continuation of the ICoreWebView2Settings interface to manage non-client regions.

Summary

Members Descriptions
get_IsNonClientRegionSupportEnabled The IsNonClientRegionSupportEnabled property enables web pages to use the app-region CSS style.
put_IsNonClientRegionSupportEnabled Set the IsNonClientRegionSupportEnabled property.

Applies to

Product Introduced
WebView2 Win32 1.0.2420.47
WebView2 Win32 Prerelease 1.0.2415

Members

get_IsNonClientRegionSupportEnabled

The IsNonClientRegionSupportEnabled property enables web pages to use the app-region CSS style.

public HRESULT get_IsNonClientRegionSupportEnabled(BOOL * enabled)

Disabling/Enabling the IsNonClientRegionSupportEnabled takes effect after the next navigation. Defaults to FALSE.

When this property is TRUE, then all the non-client region features will be enabled: Draggable Regions will be enabled, they are regions on a webpage that are marked with the CSS attribute app-region: drag/no-drag. When set to drag, these regions will be treated like the window's title bar, supporting dragging of the entire WebView and its host app window; the system menu shows upon right click, and a double click will trigger maximizing/restoration of the window size.

When set to FALSE, all non-client region support will be disabled. The app-region CSS style will be ignored on web pages.

            BOOL nonClientRegionSupportEnabled;
            wil::com_ptr<ICoreWebView2Settings9> settings;
            settings = m_settings.try_query<ICoreWebView2Settings9>();
            CHECK_FEATURE_RETURN(settings);

            CHECK_FAILURE(
                settings->get_IsNonClientRegionSupportEnabled(&nonClientRegionSupportEnabled));
            if (nonClientRegionSupportEnabled)
            {
                CHECK_FAILURE(settings->put_IsNonClientRegionSupportEnabled(FALSE));
                MessageBox(
                    nullptr,
                    L"Non-client region support will be disabled after the next navigation",
                    L"Settings change", MB_OK);
            }
            else
            {
                CHECK_FAILURE(settings->put_IsNonClientRegionSupportEnabled(TRUE));
                MessageBox(
                    nullptr,
                    L"Non-client region support will be enabled after the next navigation",
                    L"Settings change", MB_OK);
            }

put_IsNonClientRegionSupportEnabled

Set the IsNonClientRegionSupportEnabled property.

public HRESULT put_IsNonClientRegionSupportEnabled(BOOL enabled)