@@ -221,66 +221,6 @@ async Task ConfigureAndExecuteFindWithCustomUIAsync(string searchTerm)
221221}
222222// ! [ConfigureAndExecuteFindWithCustomUI]
223223```
224-
225- ### Retrieve the Number of Matches
226-
227- #### Description
228- To retrieve the total number of matches found during a find operation
229- within a WebView2 control, developers can utilize the ` GetmatchCount ` method.
230-
231-
232- ``` cpp
233- // ! [GetmatchCount ]
234- bool AppWindow::GetmatchCount ()
235- {
236- auto webView2_17 = m_webView.try_query<ICoreWebView2_17>();
237- CHECK_FEATURE_RETURN (webView2_17);
238- wil::com_ptr<ICoreWebView2Find > webView2find;
239- CHECK_FAILURE(webView2_17->get_Find(&webView2find));
240- LONG matchCount ;
241- CHECK_FAILURE(webView2find->get_MatchCount(&matchCount ));
242-
243- // Update UI or handle matchCount as you wish
244- // For example, you could show a message box
245- std::wstring matchCount Str = L"Match Count: " + std::to_wstring(matchCount );
246- MessageBox(m_mainWindow, matchCount Str.c_str(), L"Find Operation", MB_OK);
247-
248- return true;
249- }
250- //! [ GetmatchCount ]
251-
252- // Register matchCount Changed event handler
253- m_webView->add_matchCount Changed(
254- Callback<ICoreWebView2FindmatchCount ChangedEventHandler >(
255- [ this] (LONG matchCount ) -> HRESULT
256- {
257- // Update custom UI
258- wprintf(L"Match Count Changed: %ld\n", matchCount );
259- return S_OK;
260- }).Get(),
261- &m_matchCount ChangedToken);
262- ```
263-
264- ```csharp
265- //! [GetmatchCount ]
266- public async Task<int> GetmatchCount Async()
267- {
268- // Assuming webView is your WebView2 control
269- var webViewFind = webView.CoreWebView2.FindController;
270- var matchCount = await webViewFind.GetMatchCountAsync();
271- MessageBox.Show($"Match Count: {matchCount }", "Find Operation", MessageBoxButton.OK);
272- return matchCount ;
273- }
274- //! [GetmatchCount ]
275-
276- void matchCount ChangedSample()
277- {
278- _webview.matchCount Changed += (object sender, CoreWebView2matchCount ChangedEventArgs args) =>
279- {
280- // Update Custom UI
281- };
282- }
283- ```
284224
285225### Retrieve the Index of the Active Match
286226
0 commit comments