[FindTerm]
| 1644 | |
| 1645 | //! [FindTerm] |
| 1646 | bool AppWindow::FindTerm() |
| 1647 | { |
| 1648 | auto webView2_28 = m_webView.try_query<ICoreWebView2_28>(); |
| 1649 | CHECK_FEATURE_RETURN(webView2_28); |
| 1650 | wil::com_ptr<ICoreWebView2Find> webView2find; |
| 1651 | CHECK_FAILURE(webView2_28->get_Find(&webView2find)); |
| 1652 | |
| 1653 | TextInputDialog dialog( |
| 1654 | GetMainWindow(), L"Find on Page Term", L"Find on Page Term:", L"Enter Find Term"); |
| 1655 | |
| 1656 | auto m_env15 = m_webViewEnvironment.try_query<ICoreWebView2Environment15>(); |
| 1657 | CHECK_FEATURE_RETURN(m_env15); |
| 1658 | CHECK_FAILURE(webView2find->Stop()); |
| 1659 | |
| 1660 | if (!findOptions) |
| 1661 | { |
| 1662 | findOptions = SetDefaultFindOptions(); |
| 1663 | } |
| 1664 | CHECK_FAILURE(findOptions->put_FindTerm(dialog.input.c_str())); |
| 1665 | CHECK_FAILURE(webView2find->Start( |
| 1666 | findOptions.get(), Callback<ICoreWebView2FindStartCompletedHandler>( |
| 1667 | [this](HRESULT result) -> HRESULT { return S_OK; }) |
| 1668 | .Get())); |
| 1669 | return true; |
| 1670 | } |
| 1671 | //! [FindTerm] |
| 1672 | |
| 1673 | wil::com_ptr<ICoreWebView2FindOptions> AppWindow::SetDefaultFindOptions() |