Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Problem/Bug]: Incorrect ICoreWebView2FindOperationCompletedHandler usage in Find documentation #5066

Open
ajtruckle opened this issue Jan 28, 2025 · 1 comment
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@ajtruckle
Copy link

What happened?

Finally, I am unable to use the completed handler, as provided in the sample.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Prerelease (Edge Canary/Dev/Beta)

Runtime Version

134.0.391.0 canary

SDK Version

1.0.3079 prerelease

Framework

Win32

Operating System

Windows 11

OS Version

10.0.26100 24H2

Repro steps

Use provided in the sample:

		Callback<ICoreWebView2ExperimentalFindStartCompletedHandler>(
			[this](HRESULT result, BOOL status) -> HRESULT
			{
				if (SUCCEEDED(result))
				{
					// Optionally update UI elements here upon successful Find operation.
				}
				else
				{
					// Handle errors.
				}
				return S_OK;
			}).Get()) );

I had to replace it with nullptr. Otherwise I get these build errors:

6>  EdgeWebBrowser.cpp
6>  C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(354,60): error C2064: term does not evaluate to a function taking 1 arguments
6>  (compiling source file '/EdgeWebBrowser.cpp')
6>      C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(354,60):
6>      class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments
6>      C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(354,60):
6>      while trying to match the argument list '(T)'
6>          with
6>          [
6>              T=HRESULT
6>          ]
6>      C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(354,60):
6>      the template instantiation context (the oldest one first) is
6>          D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\EdgeWebBrowser.cpp(2101,3):
6>          see reference to function template instantiation 'Microsoft::WRL::ComPtr<TDelegateInterface> Microsoft::WRL::Callback<ICoreWebView2ExperimentalFindStartCompletedHandler,CWebBrowser::ConfigureAndExecuteFind::<lambda_3>>(TLambda &&) noexcept' being compiled
6>          with
6>          [
6>              TDelegateInterface=ICoreWebView2ExperimentalFindStartCompletedHandler,
6>              TLambda=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>
6>          ]
6>          C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(460,45):
6>          see reference to function template instantiation 'Microsoft::WRL::ComPtr<TDelegateInterface> Microsoft::WRL::Details::DelegateArgTraits<HRESULT (__cdecl ICoreWebView2ExperimentalFindStartCompletedHandler::* )(HRESULT)>::Callback<ICoreWebView2ExperimentalFindStartCompletedHandler,ICoreWebView2ExperimentalFindStartCompletedHandler,Microsoft::WRL::NoCheck,T>(TLambda &&) noexcept' being compiled
6>          with
6>          [
6>              TDelegateInterface=ICoreWebView2ExperimentalFindStartCompletedHandler,
6>              T=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>,
6>              TLambda=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>
6>          ]
6>          C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(367,9):
6>          while compiling class template member function 'Microsoft::WRL::ComPtr<TDelegateInterface>::ComPtr(Microsoft::WRL::ComPtr<U> &&,Details::EnableIf<Microsoft::WRL::Details::IsConvertible<U*,T*>::value,void*>::type *) noexcept'
6>          with
6>          [
6>              TDelegateInterface=ICoreWebView2ExperimentalFindStartCompletedHandler,
6>              T=ICoreWebView2ExperimentalFindStartCompletedHandler
6>          ]
6>          C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(367,9):
6>          see reference to class template instantiation 'Microsoft::WRL::Details::IsConvertible<Microsoft::WRL::Details::DelegateArgTraits<HRESULT (__cdecl ICoreWebView2ExperimentalFindStartCompletedHandler::* )(HRESULT)>::DelegateInvokeHelper<ICoreWebView2ExperimentalFindStartCompletedHandler,T,Microsoft::WRL::NoCheck,HRESULT> *,ICoreWebView2ExperimentalFindStartCompletedHandler *>' being compiled
6>          with
6>          [
6>              T=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>
6>          ]
6>          C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\internal.h(67,35):
6>          see reference to class template instantiation 'Microsoft::WRL::Details::DelegateArgTraits<HRESULT (__cdecl ICoreWebView2ExperimentalFindStartCompletedHandler::* )(HRESULT)>::DelegateInvokeHelper<ICoreWebView2ExperimentalFindStartCompletedHandler,T,Microsoft::WRL::NoCheck,HRESULT>' being compiled
6>          with
6>          [
6>              T=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>
6>          ]
6>          C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\wrl\event.h(352,35):
6>          while compiling class template member function 'HRESULT Microsoft::WRL::Details::DelegateArgTraits<HRESULT (__cdecl ICoreWebView2ExperimentalFindStartCompletedHandler::* )(HRESULT)>::DelegateInvokeHelper<ICoreWebView2ExperimentalFindStartCompletedHandler,T,Microsoft::WRL::NoCheck,HRESULT>::Invoke(HRESULT) noexcept'
6>          with
6>          [
6>              T=CWebBrowser::ConfigureAndExecuteFind::<lambda_3>
6>          ]

ChatGPT helped me with the completion handler issue and it seems the help documentation needs updating. I had to remove the BOOL status parameter so now we have:

	// Start the Find operation with a callback for completion.
	CHECK_FAILURE(webView2Find->Start(
		find_options.get(), 
		Callback<ICoreWebView2ExperimentalFindStartCompletedHandler>(
			[this](HRESULT result) -> HRESULT
			{
				if (SUCCEEDED(result))
				{
					// Optionally update UI elements here upon successful Find operation.
				}
				else
				{
					// Handle errors.
				}
				return S_OK;
			}).Get()) );
			// End user interaction is handled via UI.

The application now compiles and displays the Find dialog seamlessly—thank you for that! 🙏 However, I still believe it would be a great enhancement to include a toggle feature for the Find Options, allowing users to show or hide them as needed.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@ajtruckle ajtruckle added the bug Something isn't working label Jan 28, 2025
@chetanpandey1266 chetanpandey1266 self-assigned this Jan 30, 2025
@chetanpandey1266 chetanpandey1266 added the tracked We are tracking this work internally. label Jan 30, 2025
@chetanpandey1266
Copy link

Internal Tracking Number

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

2 participants