ContextMenuItem.Icon not Show
Posted: Fri Dec 06, 2024 3:51 am
Hi,
I try to Add ContextMenuItem.Icon, but not show icon, missing what? pls, check it, thks.
I try to Add ContextMenuItem.Icon, but not show icon, missing what? pls, check it, thks.
Code: Select all
TempArgs := TCoreWebView2ContextMenuRequestedEventArgs.Create(aArgs);
TempCollection := TCoreWebView2ContextMenuItemCollection.Create
(TempArgs.MenuItems);
try
if not(Assigned(FExecJSMenuItem)) then
begin
Ms := TMemoryStream.Create;
Ms.LoadFromFile('xx.svg');
Ms.Position := 0;
StreamAdapter := TStreamAdapter.Create(Ms, soOwned);
if WVBrowser1.CoreWebView2Environment.CreateContextMenuItem('YYY',
StreamAdapter, COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND,
TempMenuItemItf) then
try
FExecJSMenuItem := TCoreWebView2ContextMenuItem.Create
(TempMenuItemItf);
FExecJSCommandID := FExecJSMenuItem.CommandId;
FExecJSMenuItem.AddAllBrowserEvents(WVBrowser1);
finally
TempMenuItemItf := nil;
end;
end;
if Assigned(FExecJSMenuItem) and FExecJSMenuItem.Initialized then
begin
TempCollection.InsertValueAtIndex(TempCollection.Count,
FExecJSMenuItem.BaseIntf);
end;
finally
FreeAndNil(TempCollection);
FreeAndNil(TempArgs);
end;