@@ -76,10 +76,11 @@ The developer can add or remove entries to the default WebView context menu. For
7676 {
7777 wil::unique_cotaskmem_string linkUrl;
7878 CHECK_FAILURE(info->get_LinkUrl(&linkUrl));
79- m_appWindow->RunAsync([this, linkUrl]()
79+ std::wstring linkString = linkUrl.get();
80+ m_appWindow->RunAsync([this, linkString]()
8081 {
8182 MessageBox(
82- m_appWindow->GetMainWindow(), linkUrl ,
83+ m_appWindow->GetMainWindow(), linkString.c_str() ,
8384 L"Display Link", MB_OK);
8485 });
8586 return S_OK;
@@ -147,8 +148,9 @@ The developer can use the data provided in the Event arguments to display a cust
147148 CHECK_FAILURE(items->GetValueAtIndex(i, ¤t));
148149 COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND kind;
149150 CHECK_FAILURE(current->get_Kind(&kind));
150- LPWSTR label;
151+ wil::unique_cotaskmem_string label;
151152 CHECK_FAILURE(current->get_Label(&label));
153+ std::wstring labelString = label.get();
152154 BOOL isEnabled;
153155 CHECK_FAILURE(current->get_IsEnabled(&isEnabled));
154156 BOOL isChecked;
@@ -162,20 +164,20 @@ The developer can use the data provided in the Event arguments to display a cust
162164 else if (kind == COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SUBMENU)
163165 {
164166 HMENU newMenu = CreateMenu();
165- wil::com_ptr<ICoreWebView2ContextMenuItemCollection> SubmenuItems ;
166- CHECK_FAILURE(current->get_Children(&SubmenuItems ));
167- AddMenuItems(newMenu, SubmenuItems );
168- AppendMenu(hPopupMenu, MF_POPUP, (UINT_PTR)newMenu, label );
167+ wil::com_ptr<ICoreWebView2ContextMenuItemCollection> submenuItems ;
168+ CHECK_FAILURE(current->get_Children(&submenuItems ));
169+ AddMenuItems(newMenu, submenuItems );
170+ AppendMenu(hPopupMenu, MF_POPUP, (UINT_PTR)newMenu, labelString.c_str() );
169171 }
170172 else if (kind == COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_NORMAL)
171173 {
172174 if (isEnabled)
173175 {
174- AppendMenu(hPopupMenu, MF_BYPOSITION | MF_STRING, commandId, label );
176+ AppendMenu(hPopupMenu, MF_BYPOSITION | MF_STRING, commandId, labelString.c_str() );
175177 }
176178 else
177179 {
178- AppendMenu(hPopupMenu, MF_GRAYED | MF_STRING, commandId, label );
180+ AppendMenu(hPopupMenu, MF_GRAYED | MF_STRING, commandId, labelString.c_str() );
179181 }
180182 }
181183 else if (
@@ -186,23 +188,23 @@ The developer can use the data provided in the Event arguments to display a cust
186188 {
187189 if (isChecked)
188190 {
189- AppendMenu(hPopupMenu, MF_CHECKED | MF_STRING, commandId, label );
191+ AppendMenu(hPopupMenu, MF_CHECKED | MF_STRING, commandId, labelString.c_str() );
190192 }
191193 else
192194 {
193- AppendMenu(hPopupMenu, MF_BYPOSITION | MF_STRING, commandId, label );
195+ AppendMenu(hPopupMenu, MF_BYPOSITION | MF_STRING, commandId, labelString.c_str() );
194196 }
195197 }
196198 else
197199 {
198200 if (isChecked)
199201 {
200202 AppendMenu(
201- hPopupMenu, MF_CHECKED | MF_GRAYED | MF_STRING, commandId, label );
203+ hPopupMenu, MF_CHECKED | MF_GRAYED | MF_STRING, commandId, labelString.c_str() );
202204 }
203205 else
204206 {
205- AppendMenu(hPopupMenu, MF_GRAYED | MF_STRING, commandId, label );
207+ AppendMenu(hPopupMenu, MF_GRAYED | MF_STRING, commandId, labelString.c_str() );
206208 }
207209 }
208210 }
@@ -423,7 +425,7 @@ The developer can use the data provided in the Event arguments to display a cust
423425 /// Gets the localized label for the `ContextMenuItem`.
424426 [propget] HRESULT Label([out, retval] LPWSTR* value);
425427
426- /// Get the unlocalized name for the `ContextMenuItem`. Use this to distinguish items with
428+ /// Gets the unlocalized name for the `ContextMenuItem`. Use this to distinguish items with
427429 /// same Descriptor such as Extension items and items with Other as descriptor.
428430 [propget] HRESULT Name([out, retval] LPWSTR* value);
429431
@@ -471,7 +473,7 @@ The developer can use the data provided in the Event arguments to display a cust
471473 [uuid(f562a2f5-c415-45cf-b909-d4b7c1e276d3), object, pointer_default(unique)]
472474 interface ICoreWebView2ContextMenuItemCollection : IUnknown
473475 {
474- /// The number of `ContextMenuItem` objects contained in the `ContextMenuItemCollection`.
476+ /// Gets the number of `ContextMenuItem` objects contained in the `ContextMenuItemCollection`.
475477 [propget] HRESULT Count([out, retval] UINT32* value);
476478
477479 /// Gets the `ContextMenuItem` at the specified index.
0 commit comments