Skip to content

Commit 6df85f0

Browse files
committed
Update to adress latest comments
1 parent bad09b9 commit 6df85f0

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

specs/CoreWebView2ControllerOptions.DefaultBackgroundColor.md

+24-15
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,29 @@ applies the color too late.
3030
wil::com_ptr<ICoreWebView2ControllerOptions> options;
3131
HRESULT hr = m_environment->CreateCoreWebView2ControllerOptions(&options);
3232

33-
wil::com_ptr<ICoreWebView2ControllerOptions> stagingOptions;
33+
if (hr == E_INVALIDARG)
34+
{
35+
return S_OK;
36+
}
37+
38+
wil::com_ptr<ICoreWebView2ControllerOptions> stagingOptions;wil::com_ptr<ICoreWebView2ControllerOptions4> options4;
3439
auto result = options->QueryInterface(IID_PPV_ARGS(&stagingOptions));
3540

41+
42+
3643
if (SUCCEEDED(result))
3744
{
3845
COREWEBVIEW2_COLOR wvColor{255, 223, 225, 225};
3946
stagingOptions->put_DefaultBackgroundColor(wvColor);
40-
41-
m_environment->CreateCoreWebView2Controller(
42-
m_mainWindow, options.Get(),
43-
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
44-
this, &AppWindow::OnCreateCoreWebView2ControllerCompleted).Get());
4547
}
4648

49+
m_environment->CreateCoreWebView2Controller(
50+
m_mainWindow, options.Get(),
51+
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
52+
this, &AppWindow::OnCreateCoreWebView2ControllerCompleted).Get());
53+
54+
return S_OK;
55+
4756
}
4857
```
4958

@@ -59,9 +68,10 @@ SetDefaultBackgroundColor();
5968

6069
private void SetDefaultBackgroundColor()
6170
{
62-
CoreWebView2ControllerOptions options = WebView2.CoreWebView2.Environment.CreateCoreWebView2ControllerOptions();
71+
CoreWebView2Environment environment = CoreWebView2Environment.CreateAsync();
72+
CoreWebView2ControllerOptions options = environment.CreateCoreWebView2ControllerOptions();
6373
options.DefaultBackgroundColor = Color.FromArgb(0, 0, 255);
64-
WebView2.CoreWebView2.Environment.CreateCoreWebView2ControllerAsync(parentHwnd, options);
74+
WebView2.EnsureCoreWebView2Async(environment, options);
6575
}
6676

6777
```
@@ -87,15 +97,14 @@ interface ICoreWebView2ControllerOptions4 : IUnknown {
8797
///
8898
/// The `DefaultBackgroundColor` is the color that renders underneath all web
8999
/// content. This means WebView renders this color when there is no web
90-
/// content loaded. It is important to note that the default color is white.
100+
/// content loaded. When no background color is defined in WebView2, it uses
101+
/// the `DefaultBackgroundColor` property to render the background.
102+
/// By default, this color is set to white.
103+
///
91104
/// Currently this API only supports opaque colors and transparency. It will
92105
/// fail for colors with alpha values that don't equal 0 or 255 ie. translucent
93-
/// colors are not supported. It also does not support transparency on Windows 7.
94-
/// On Windows 7, setting DefaultBackgroundColor to a Color with an Alpha value
95-
/// other than 255 will result in failure. On any OS above Win7, choosing a
96-
/// transparent color will result in showing hosting app content. This means
97-
/// webpages without explicit background properties defined will render web
98-
/// content over hosting app content.
106+
/// colors are not supported. When WebView2 is set to have a transparent background,
107+
/// it renders the content of the parent window behind it.
99108

100109
[propget] HRESULT DefaultBackgroundColor([out, retval] COREWEBVIEW2_COLOR* value);
101110
[propput] HRESULT DefaultBackgroundColor([in] COREWEBVIEW2_COLOR value);

0 commit comments

Comments
 (0)