-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create FindOnPage.md #4399
Open
maxwellmyers
wants to merge
81
commits into
main
Choose a base branch
from
api-findonpage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+611
−0
Open
Create FindOnPage.md #4399
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
fe8893d
Create FindOnPage.md
maxwellmyers eae4c7e
Update FindOnPage.md
maxwellmyers 6c2f522
Update FindOnPage.md
maxwellmyers 18600e6
Update FindOnPage.md
maxwellmyers f2c8a40
Update FindOnPage.md
maxwellmyers 27cc5a1
Update FindOnPage.md
maxwellmyers 866f3fe
Update FindOnPage.md
maxwellmyers bdcfbb5
Update FindOnPage.md
maxwellmyers bcb312d
Update FindOnPage.md
maxwellmyers 0cbebb2
Update FindOnPage.md
maxwellmyers b88741d
Update FindOnPage.md
maxwellmyers 9d9ef6d
Update FindOnPage.md
maxwellmyers 09c3bd8
Update FindOnPage.md
maxwellmyers 15050e2
Update FindOnPage.md
maxwellmyers 121afee
Update FindOnPage.md
maxwellmyers 83a0f0c
Update FindOnPage.md
maxwellmyers b1a63fb
Update FindOnPage.md
maxwellmyers af525b6
Update FindOnPage.md
maxwellmyers 52ba7d4
Update FindOnPage.md
maxwellmyers e6c8905
Update FindOnPage.md
maxwellmyers 42b3cdd
Update FindOnPage.md
maxwellmyers f0b9e32
Update FindOnPage.md
maxwellmyers 2320ee1
Update FindOnPage.md
maxwellmyers 5e54814
Update FindOnPage.md
maxwellmyers 151f501
Update FindOnPage.md
maxwellmyers 87f7dba
deleted 438-443
maxwellmyers e66ba7a
deleted usage example from the api def
maxwellmyers 0a6971e
line length corrected
maxwellmyers 4c87604
217 to 2_17
maxwellmyers d28354a
Update FindOnPage.md
maxwellmyers 4de44af
Updated Callback in StartFind and the description of the find op comp…
maxwellmyers b3b07ae
Updated the Configure/Execute Find
maxwellmyers a74ffa9
Created a flow for using custom dialog and default dialog within star…
maxwellmyers a33d8c0
Update FindOnPage.md
maxwellmyers cb1913d
Update FindOnPage.md
maxwellmyers fcf1ebb
Update FindOnPage.md
maxwellmyers 990ed88
Update FindOnPage.md
maxwellmyers 2f71770
Update FindOnPage.md
maxwellmyers eeceaf0
Update FindOnPage.md
maxwellmyers e0a860c
Update FindOnPage.md
maxwellmyers 5f4f6c7
Update FindOnPage.md
maxwellmyers 7d1db17
Update FindOnPage.md
maxwellmyers b4e4f7d
Update FindOnPage.md
maxwellmyers 9c6460b
Update FindOnPage.md
maxwellmyers f68c12c
Update FindOnPage.md
maxwellmyers 7528998
Update FindOnPage.md
maxwellmyers 374292a
Update FindOnPage.md
maxwellmyers e5cde96
Changed search to find
maxwellmyers 1315049
Update FindOnPage.md
maxwellmyers 0f40d23
Update FindOnPage.md
maxwellmyers 9e9f995
Update FindOnPage.md
maxwellmyers 6dd9024
Update FindOnPage.md
maxwellmyers 24c70af
Update FindOnPage.md
maxwellmyers db2d318
Update FindOnPage.md
maxwellmyers 57389cf
Update FindOnPage.md
maxwellmyers b9a14b6
changed shouldhighlight and supress dialiog
maxwellmyers 0d2f601
Update FindOnPage.md
maxwellmyers 99a713f
Update FindOnPage.md
maxwellmyers 6ccdf17
Update FindOnPage.md
maxwellmyers b20d9a6
Update FindOnPage.md
maxwellmyers 4788c42
Update FindOnPage.md
maxwellmyers d4be4a6
Update FindOnPage.md
maxwellmyers aa1a1e5
Update FindOnPage.md
maxwellmyers d2b65a2
Update FindOnPage.md
maxwellmyers c40a79b
added 2 default UI screenshots
maxwellmyers c062611
Update FindOnPage.md
maxwellmyers 18ea6f5
Update FindOnPage.md
maxwellmyers c4988da
Update FindOnPage.md
maxwellmyers 99bfd11
Update FindOnPage.md
maxwellmyers 6eeaf1e
Changed FindConfig -> FindOptions
maxwellmyers 05838bf
Update FindOnPage.md
maxwellmyers 7e99d7d
Update FindOnPage.md
maxwellmyers 3e608aa
Update FindOnPage.md
maxwellmyers c619dbb
Update FindOnPage.md
maxwellmyers 3ed7d68
Update FindOnPage.md
maxwellmyers 571626f
Update FindOnPage.md
maxwellmyers 4257d86
Update FindOnPage.md
maxwellmyers 5e6d5dd
Update FindOnPage.md
maxwellmyers d1299fc
Update FindOnPage.md
maxwellmyers 1675000
Update FindOnPage.md with experimental find options/
maxwellmyers d1b34c0
Update FindOnPage.md for find session terminology
maxwellmyers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading status checks…
Update FindOnPage.md
commit bcb312dd40dc49a4aa028683cf3dd38d597d1787
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,31 @@ bool AppWindow::ConfigureAndExecuteFind( | |
return ExecuteFindOperation(findConfiguration.get()); | ||
} | ||
``` | ||
```csharp | ||
bool AppWindow::ConfigureAndExecuteFind( | ||
const std::wstring& searchTerm, | ||
bool caseSensitive, | ||
bool highlightAllMatches, | ||
COREWEBVIEW2_FIND_DIRECTION direction) | ||
{ | ||
// Query for the ICoreWebView2StagingEnvironment5 interface. | ||
auto webView2Environment5 = m_webViewEnvironment.try_query<ICoreWebView2StagingEnvironment5>(); | ||
CHECK_FEATURE_RETURN(webView2Environment5); | ||
|
||
// Create the find configuration. | ||
wil::com_ptr<ICoreWebView2StagingFindConfiguration> findConfiguration; | ||
CHECK_FAILURE(webView2Environment5->CreateFindConfiguration(&findConfiguration)); | ||
|
||
// Apply the find operation configurations. | ||
CHECK_FAILURE(findConfiguration->put_FindTerm(searchTerm.c_str())); | ||
CHECK_FAILURE(findConfiguration->put_IsCaseSensitive(caseSensitive)); | ||
CHECK_FAILURE(findConfiguration->put_ShouldHighlightAllMatches(highlightAllMatches)); | ||
CHECK_FAILURE(findConfiguration->put_FindDirection(direction)); | ||
|
||
// Proceed to execute the find operation with the configured settings. | ||
return ExecuteFindOperation(findConfiguration.get()); | ||
} | ||
``` | ||
### Start a Find Operation | ||
|
||
```cpp | ||
|
@@ -81,6 +105,46 @@ bool AppWindow::ExecuteFindOperation(ICoreWebView2StagingFindConfiguration* conf | |
return SUCCEEDED(result); | ||
} | ||
|
||
//! [StartFindOnPage] | ||
``` | ||
```csharp | ||
//! [StartFindOnPage] | ||
bool AppWindow::ExecuteFindOperation(ICoreWebView2StagingFindConfiguration* configuration) | ||
{ | ||
// Query for the ICoreWebView2Staging17 interface to access the Find feature. | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
|
||
// Get the Find interface. | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
|
||
// Apply custom UI settings and highlight configurations. | ||
CHECK_FAILURE(webView2stagingfind->put_UseCustomUI(false)); // Assuming you want to use the default UI, adjust as necessary. | ||
CHECK_FAILURE(webView2stagingfind->put_ShouldHighlightAllMatches(true)); // This should match the passed parameter if dynamic. | ||
CHECK_FAILURE(webView2stagingfind->PassHighlightSettings()); | ||
|
||
// Start the find operation with the configured findConfiguration. | ||
HRESULT result = webView2stagingfind->StartFind( | ||
configuration, | ||
Callback<ICoreWebView2StagingFindOperationCompletedHandler>( | ||
[this](HRESULT result, LONG ActiveIdx, LONG MatchesCount) -> HRESULT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't match your COM IDL which says
|
||
{ | ||
if (SUCCEEDED(result)) | ||
{ | ||
// Handle successful find operation | ||
// For example, updating UI elements to reflect the find results | ||
} | ||
else | ||
{ | ||
// Handle errors appropriately | ||
} | ||
return S_OK; | ||
}).Get()); | ||
|
||
return SUCCEEDED(result); | ||
} | ||
|
||
//! [StartFindOnPage] | ||
``` | ||
### Stop an existing find operation | ||
|
@@ -99,6 +163,19 @@ bool AppWindow::StopFind() | |
} | ||
//! [StopFind] | ||
``` | ||
```csharp | ||
//! [StopFind] | ||
bool AppWindow::StopFind() | ||
{ | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
CHECK_FAILURE(webView2stagingfind->StopFind()); | ||
return true; | ||
} | ||
//! [StopFind] | ||
``` | ||
|
||
### Retrieve the Number of Matches | ||
|
||
|
@@ -126,6 +203,26 @@ bool AppWindow::GetMatchCount() | |
} | ||
//! [GetMatchCount] | ||
``` | ||
```csharp | ||
//! [GetMatchCount] | ||
bool AppWindow::GetMatchCount() | ||
{ | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
LONG matchCount; | ||
CHECK_FAILURE(webView2stagingfind->get_MatchesCount(&matchCount)); | ||
|
||
// Update UI or handle matchCount as you wish | ||
// For example, you could show a message box | ||
std::wstring matchCountStr = L"Match Count: " + std::to_wstring(matchCount); | ||
MessageBox(m_mainWindow, matchCountStr.c_str(), L"Find Operation", MB_OK); | ||
|
||
return true; | ||
} | ||
//! [GetMatchCount] | ||
``` | ||
#### Handle Match Count Changes | ||
|
||
```cpp | ||
|
@@ -135,6 +232,14 @@ void OnMatchCountChanged(LONG matchesCount) | |
// Update UI elements or perform actions based on the new match count | ||
} | ||
``` | ||
|
||
```csharp | ||
void OnMatchCountChanged(LONG matchesCount) | ||
{ | ||
// Handle match count changes | ||
// Update UI elements or perform actions based on the new match count | ||
} | ||
``` | ||
### Retrieve the Index of the Active Match | ||
|
||
#### Description | ||
|
@@ -163,6 +268,28 @@ bool AppWindow::GetActiveMatchIndex() | |
//! [GetActiveMatchIndex] | ||
``` | ||
|
||
```csharp | ||
//! [GetActiveMatchIndex] | ||
bool AppWindow::GetActiveMatchIndex() | ||
{ | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
LONG activeMatchIndex; | ||
CHECK_FAILURE(webView2stagingfind->get_ActiveMatchIndex(&activeMatchIndex)); | ||
|
||
// Update UI or handle activeMatchIndex as you wish | ||
// For example, you could show a message box | ||
std::wstring activeMatchIndexStr = | ||
L"Active Match Index: " + std::to_wstring(activeMatchIndex); | ||
MessageBox(m_mainWindow, activeMatchIndexStr.c_str(), L"Find Operation", MB_OK); | ||
|
||
return true; | ||
} | ||
//! [GetActiveMatchIndex] | ||
``` | ||
|
||
#### Handle Active Match Index Changes | ||
```cpp | ||
void OnActiveMatchIndexChanged(ICoreWebView2* sender, ICoreWebView2StagingFindActiveMatchIndexChangedEventArgs* args) | ||
|
@@ -172,6 +299,14 @@ void OnActiveMatchIndexChanged(ICoreWebView2* sender, ICoreWebView2StagingFindAc | |
} | ||
``` | ||
|
||
```csharp | ||
void OnActiveMatchIndexChanged(ICoreWebView2* sender, ICoreWebView2StagingFindActiveMatchIndexChangedEventArgs* args) | ||
{ | ||
// Handle active match index changes | ||
// Update UI to reflect the change in the active match index | ||
} | ||
``` | ||
|
||
### Navigate to the Next Match | ||
|
||
#### Description | ||
|
@@ -196,6 +331,24 @@ bool AppWindow::FindNext() | |
//! [FindNext] | ||
``` | ||
|
||
```csharp | ||
//! [FindNext] | ||
bool AppWindow::FindNext() | ||
{ | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
|
||
CHECK_FAILURE(webView2stagingfind->FindNext()); | ||
CHECK_FAILURE(webView2stagingfind->remove_ActiveMatchIndexChanged( | ||
m_ActiveMatchIndexChangedEventToken)); | ||
|
||
return true; | ||
} | ||
//! [FindNext] | ||
``` | ||
|
||
### Navigate to the Previous Match | ||
|
||
#### Description | ||
|
@@ -218,6 +371,22 @@ bool AppWindow::FindPrevious() | |
//! [FindPrevious] | ||
``` | ||
|
||
```csharp | ||
//! [FindPrevious] | ||
bool AppWindow::FindPrevious() | ||
{ | ||
auto webView2staging17 = m_webView.try_query<ICoreWebView2Staging17>(); | ||
CHECK_FEATURE_RETURN(webView2staging17); | ||
wil::com_ptr<ICoreWebView2StagingFind> webView2stagingfind; | ||
CHECK_FAILURE(webView2staging17->get_Find(&webView2stagingfind)); | ||
|
||
CHECK_FAILURE(webView2stagingfind->FindPrevious()); | ||
|
||
return true; | ||
} | ||
//! [FindPrevious] | ||
``` | ||
|
||
## API Details | ||
maxwellmyers marked this conversation as resolved.
Show resolved
Hide resolved
maxwellmyers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```csharp | ||
maxwellmyers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHECK_FEATURE_RETURN_EMPTY
? (I can't find definitions of these macros, but it seems that the caller expects null to be returned on failure.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please validate. Follow up with me if there's something in WIL or something more standard we can use instead throughout our sample app code.