Skip to content

Commit 6fb51a0

Browse files
authored
Update CoreWebView2.CreateFromCOMObject.md
1 parent d3ecd27 commit 6fb51a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

specs/CoreWebView2.CreateFromCOMObject.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ public class MyWebView2Control
2525
{
2626
... // Regular control code
2727
28-
// A previously created ICoreWebView2
29-
IntPtr _myCoreWebView2ComObject = ...;
30-
3128
CoreWebView2 _myCoreWebView2 = null;
3229

30+
[DllImport(DLL_NAME, CallingConvention = CallingConvention.StdCall)]
31+
public static extern ComNativePointer GetNativePointer(WebViewInstancePtr instanceId);
32+
3333
// This is the CoreWebView2 property which allows developers to access CoreWebView2 APIs directly.
3434
public CoreWebView2 CoreWebView2
3535
{
3636
get
3737
{
3838
if (!_myCoreWebView2)
3939
{
40-
_myCoreWebView2 = CoreWebView2.CreateFromComObject(_myCoreWebView2Object);
40+
IntPtr comPtr = WebViewNative.GetNativePointer(InstanceId);
41+
42+
_myCoreWebView2 = CoreWebView2.CreateFromComObject(comPtr);
4143
}
4244
return _myCoreWebView2;
4345
}

0 commit comments

Comments
 (0)