Skip to content

Commit fcf1ebb

Browse files
authored
Update FindOnPage.md
1 parent cb1913d commit fcf1ebb

1 file changed

Lines changed: 55 additions & 67 deletions

File tree

FindOnPage.md

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -226,90 +226,62 @@ async Task ConfigureAndExecuteFindWithCustomUIAsync(string searchTerm)
226226

227227
#### Description
228228
To retrieve the total number of matches found during a find operation
229-
within a WebView2 control, developers can utilize the `GetMatchCount` method.
229+
within a WebView2 control, developers can utilize the `GetmatchCount ` method.
230230

231231

232232
```cpp
233-
//! [GetMatchCount]
234-
bool AppWindow::GetMatchCount()
233+
//! [GetmatchCount ]
234+
bool AppWindow::GetmatchCount ()
235235
{
236236
auto webView2_17 = m_webView.try_query<ICoreWebView2_17>();
237237
CHECK_FEATURE_RETURN(webView2_17);
238238
wil::com_ptr<ICoreWebView2Find> webView2find;
239239
CHECK_FAILURE(webView2_17->get_Find(&webView2find));
240-
LONG matchCount;
241-
CHECK_FAILURE(webView2find->get_MatchesCount(&matchCount));
240+
LONG matchCount ;
241+
CHECK_FAILURE(webView2find->get_MatchesCount(&matchCount ));
242242

243-
// Update UI or handle matchCount as you wish
243+
// Update UI or handle matchCount as you wish
244244
// For example, you could show a message box
245-
std::wstring matchCountStr = L"Match Count: " + std::to_wstring(matchCount);
246-
MessageBox(m_mainWindow, matchCountStr.c_str(), L"Find Operation", MB_OK);
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);
247247

248248
return true;
249249
}
250-
//! [GetMatchCount]
251-
```
250+
//! [GetmatchCount ]
252251

253-
```csharp
254-
//! [GetMatchCount]
255-
public async Task<int> GetMatchCountAsync()
256-
{
257-
// Assuming webView is your WebView2 control
258-
var webViewFind = webView.CoreWebView2.FindController;
259-
var matchCount = await webViewFind.GetMatchesCountAsync();
260-
MessageBox.Show($"Match Count: {matchCount}", "Find Operation", MessageBoxButton.OK);
261-
return matchCount;
262-
}
263-
//! [GetMatchCount]
264-
```
265-
#### WIN32 C++
266-
```cpp
267-
// Register MatchCountChanged event handler
268-
m_webView->add_MatchCountChanged(
269-
Callback<ICoreWebView2FindMatchCountChangedEventHandler>(
270-
[this](LONG matchCount) -> HRESULT
252+
// Register matchCount Changed event handler
253+
m_webView->add_matchCount Changed(
254+
Callback<ICoreWebView2FindmatchCount ChangedEventHandler>(
255+
[this](LONG matchCount ) -> HRESULT
271256
{
272257
// Update custom UI
273-
wprintf(L"Match Count Changed: %ld\n", matchCount);
258+
wprintf(L"Match Count Changed: %ld\n", matchCount );
274259
return S_OK;
275260
}).Get(),
276-
&m_matchCountChangedToken);
261+
&m_matchCount ChangedToken);
277262
```
278-
#### .NET C#
263+
279264
```csharp
280-
void MatchCountChangedSample()
281-
{
282-
_webview.MatchCountChanged += (object sender, CoreWebView2MatchCountChangedEventArgs args) =>
265+
//! [GetmatchCount ]
266+
public async Task<int> GetmatchCount Async()
283267
{
284-
// Update Custom UI
285-
};
286-
}
287-
```
288-
#### Handle Match Index Changes
289-
#### WIN32 C++
268+
// Assuming webView is your WebView2 control
269+
var webViewFind = webView.CoreWebView2.FindController;
270+
var matchCount = await webViewFind.GetMatchesCountAsync();
271+
MessageBox.Show($"Match Count: {matchCount }", "Find Operation", MessageBoxButton.OK);
272+
return matchCount ;
273+
}
274+
//! [GetmatchCount ]
290275
291-
```cpp
292-
// Register ActiveMatchIndexChanged event handler
293-
m_webView->add_ActiveMatchIndexChanged(
294-
Callback<ICoreWebView2FindActiveMatchIndexChangedEventHandler>(
295-
[this](LONG activeMatchIndex) -> HRESULT
296-
{
297-
// Update custom UI
298-
wprintf(L"Active Match Index Changed: %ld\n", activeMatchIndex);
299-
return S_OK;
300-
}).Get(),
301-
&m_activeMatchIndexChangedToken);
302-
```
303-
#### .NET C#
304-
```csharp
305-
void ActiveMatchIndexChangedSample()
306-
{
307-
_webview.MatchCountChanged += (object sender, CoreWebView2ActiveMatchIndexChangedEventArgs args) =>
276+
void matchCount ChangedSample()
308277
{
309-
// Update Custom UI
310-
};
311-
}
278+
_webview.matchCount Changed += (object sender, CoreWebView2matchCount ChangedEventArgs args) =>
279+
{
280+
// Update Custom UI
281+
};
282+
}
312283
```
284+
313285
### Retrieve the Index of the Active Match
314286

315287
#### Description
@@ -337,6 +309,17 @@ within a WebView2 control using the `GetActiveMatchIndex` method.
337309
return true;
338310
}
339311
//! [GetActiveMatchIndex]
312+
313+
// Register ActiveMatchIndexChanged event handler
314+
m_webView->add_ActiveMatchIndexChanged(
315+
Callback<ICoreWebView2FindActiveMatchIndexChangedEventHandler>(
316+
[this](LONG activeMatchIndex) -> HRESULT
317+
{
318+
// Update custom UI
319+
wprintf(L"Active Match Index Changed: %ld\n", activeMatchIndex);
320+
return S_OK;
321+
}).Get(),
322+
&m_activeMatchIndexChangedToken);
340323
```
341324
#### .NET C#
342325
```csharp
@@ -349,11 +332,16 @@ public async Task<int> GetActiveMatchIndexAsync()
349332
return activeMatchIndex;
350333
}
351334
335+
void ActiveMatchIndexChangedSample()
336+
{
337+
_webview.matchCount Changed += (object sender, CoreWebView2ActiveMatchIndexChangedEventArgs args) =>
338+
{
339+
// Update Custom UI
340+
};
341+
}
352342
//! [GetActiveMatchIndex]
353343
```
354344

355-
356-
357345
## API Details
358346
```csharp
359347

@@ -413,7 +401,7 @@ interface ICoreWebView2FindConfiguration : IUnknown {
413401

414402
/// Handles the event that's fired when the match count changes.
415403
[uuid(623EFBFB-A19E-43C4-B309-D578511D24AB), object, pointer_default(unique)]
416-
interface ICoreWebView2FindMatchCountChangedEventHandler : IUnknown {
404+
interface ICoreWebView2FindmatchCount ChangedEventHandler : IUnknown {
417405
/// Parameter is the match count.
418406
HRESULT Invoke(LONG matchesCount);
419407
}
@@ -453,12 +441,12 @@ interface ICoreWebView2Find : IUnknown {
453441
// This event is raised when a find operation completes, either by finding all matches, navigating to a match, or by being stopped.
454442
// Parameter is the event handler to be added.
455443
// Returns a token representing the added event handler. This token can be used to unregister the event handler.
456-
HRESULT add_MatchCountChanged(
457-
[in] ICoreWebView2FindMatchCountChangedEventHandler* eventHandler,
444+
HRESULT add_matchCount Changed(
445+
[in] ICoreWebView2FindmatchCount ChangedEventHandler* eventHandler,
458446
[out] EventRegistrationToken* token);
459-
// Unregisters an event handler from the MatchCountChanged event.
447+
// Unregisters an event handler from the matchCount Changed event.
460448
// Parameter is the token of the event handler to be removed, obtained during the registration of the event handler.
461-
HRESULT remove_MatchCountChanged([in] EventRegistrationToken token);
449+
HRESULT remove_matchCount Changed([in] EventRegistrationToken token);
462450

463451
// Registers an event handler for the ActiveMatchIndexChanged event.
464452
// This event is raised when the index of the currently active match changes.

0 commit comments

Comments
 (0)