You can do that at the application level, preventing some messages to be forwarded to the TWebBrowser
component. For example by using a TApplicationEvents
component and its OnMessage
event handler:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (
//keyboard
(Msg.message = WM_KEYDOWN)
//right click, for avoid copy-paste from popupmenu
(Msg.Message = WM_RBUTTONDOWN) or
(Msg.Message = WM_RBUTTONDBLCLK) or
) then
begin
if IsChild(WebBrowser1.Handle, Msg.hwnd) then
begin
Handled := True;
end;
end;
end;
A cleaner solution could be to suppress such messages at the component level, but unforntunately I've never found a way to make that works with the TWebBrowser
component