[MSW] wxWebViewEdge - using experimental API

112 views
Skip to first unread message

Eric Jensen

unread,
Jul 18, 2021, 10:00:07 AM7/18/21
to wx-u...@googlegroups.com
Hi all,

I need the option to enable saving forms and passwords in wxWebViewEdge.

An experimental API exists for that:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2experimentalsettings3?view=webview2-1.0.865-prerelease

So, what i need is a ICoreWebView2ExperimentalSettings3. Unforunately
i know hardly anything about COM programming and i'm pretty lost right
now.

This is as far as got:
wxWebViewEdgeImpl *impl = static_cast<wxWebViewEdgeImpl*>(m_browser->GetNativeBackend());
ICoreWebView2Settings *settings = impl->GetSettings();

Can i get a ICoreWebView2ExperimentalSettings3 from here, or do i need
to get into the wxWebViewEdge implementation source?

Thanks for any hints.

Eric

Maarten Bent

unread,
Jul 18, 2021, 12:14:22 PM7/18/21
to wx-u...@googlegroups.com
Hi,

GetNativeBackend returns the ICoreWebView2, not the wxWebViewEdgeImpl.
Something like this works for me with ICoreWebView2Settings3 and the latest webview2 sdk. I suppose you can do something similar with ICoreWebView2ExperimentalSettings3.
(It compiles, I don't know if it works. It also should have error checks. I added wxCOMPtr to all the pointers so they are cleaned up on exit, maybe verify if this is needed.)

wxCOMPtr<ICoreWebView2> impl((ICoreWebView2*)m_browser->GetNativeBackend());
ICoreWebView2Settings* settingsPtr;
impl->get_Settings(&settingsPtr);
wxCOMPtr<ICoreWebView2Settings> settings(settingsPtr);
ICoreWebView2Settings3* settings3Ptr;
settings->QueryInterface(&settings3Ptr);
wxCOMPtr<ICoreWebView2Settings3> settings3(settings3Ptr);
settings3->put_AreBrowserAcceleratorKeysEnabled(false);

Maarten

Eric Jensen

unread,
Jul 18, 2021, 3:22:09 PM7/18/21
to Maarten Bent
Hello Maarten,

Sunday, July 18, 2021, 6:14:19 PM, you wrote:

MB> Hi,

MB> GetNativeBackend returns the ICoreWebView2, not the wxWebViewEdgeImpl.
MB> Something like this works for me with ICoreWebView2Settings3 and
MB> the latest webview2 sdk. I suppose you can do something similar
MB> with ICoreWebView2ExperimentalSettings3.
MB> (It compiles, I don't know if it works. It also should have error
MB> checks. I added wxCOMPtr to all the pointers so they are cleaned
MB> up on exit, maybe verify if this is needed.)

MB> wxCOMPtr<ICoreWebView2>
MB> impl((ICoreWebView2*)m_browser->GetNativeBackend());
MB> ICoreWebView2Settings* settingsPtr;
impl->>get_Settings(&settingsPtr);
MB> wxCOMPtr<ICoreWebView2Settings> settings(settingsPtr);
MB> ICoreWebView2Settings3* settings3Ptr;
settings->>QueryInterface(&settings3Ptr);
MB> wxCOMPtr<ICoreWebView2Settings3> settings3(settings3Ptr);
settings3->>put_AreBrowserAcceleratorKeysEnabled(false);

based on your hints, i got it to work.

Thanks a lot!

Regards,
Eric

Reply all
Reply to author
Forward
0 new messages