delphitwebbrowsertembeddedwb

Disable keyboard on TWebBrowser in Delphi


I want Disable Keyboard for TWebBrowser and avoid copying information inside it using Ctrl+C. but I couldn't find any option for disable keyboard in TWebBrowser properties.

Is there a way to do this?

EDIT: I saw this solution but it doesn't work. Disable All Keypresses


Solution

  • @Fabrizio

    Thank you for your code. this code can not Disable Keyboard for TWebBrowser. For this problem I found a component called EmbeddedWB. It have options for disable context menu.

    Now Compound Options with your code (with a little change) makes text copying completely disabled.

    procedure TMainForm.ApplicationEventsMessage(var Msg: tagMSG;
     var Handled: Boolean);
    begin
     if ((Msg.message=WM_RBUTTONDOWN) or (Msg.message=WM_RBUTTONUP) or 
        (Msg.message=WM_KEYDOWN) or (Msg.message=WM_KEYUP)) and 
        IsChild(WebBrowser.Handle,Msg.hwnd) then
        begin
         PopupMenu.Popup(Msg.pt.X,Msg.pt.Y);
         Handled:=true;
     end;
    

    end;