MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / Start

Method Start

SampleApps/WebView2APISample/AppWindow.cpp:1425–1453  ·  view source on GitHub ↗

[Start]

Source from the content-addressed store, hash-verified

1423
1424//! [Start]
1425bool AppWindow::Start(const std::wstring& searchTerm)
1426{
1427 auto webView2_28 = m_webView.try_query<ICoreWebView2_28>();
1428 CHECK_FEATURE_RETURN(webView2_28);
1429
1430 wil::com_ptr<ICoreWebView2Find> webView2find;
1431 CHECK_FAILURE(webView2_28->get_Find(&webView2find));
1432 SetupFindEventHandlers(webView2find);
1433
1434 // Initialize find configuration/settings
1435 if (!findOptions)
1436 {
1437 findOptions = SetDefaultFindOptions();
1438 }
1439
1440 // Check if the search term has changed to determine if UI needs to be updated
1441 if (m_findOnPageLastSearchTerm != searchTerm)
1442 {
1443 m_findOnPageLastSearchTerm =
1444 searchTerm; // Update the last search term for future comparisons
1445 }
1446
1447 // Start the find operation
1448 CHECK_FAILURE(webView2find->Start(
1449 findOptions.get(), Callback<ICoreWebView2FindStartCompletedHandler>(
1450 [this](HRESULT result) -> HRESULT { return S_OK; })
1451 .Get()));
1452 return true;
1453}
1454//! [Start]
1455
1456//! [FindNext]

Calls

no outgoing calls

Tested by

no test coverage detected