在Form放置一个ApplicationEvents控件,
在OnMessage事件中写下面的代码:
uses ActiveX
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
const
StdKeys = [VK_TAB, VK_RETURN, VK_DELETE, VK_BACK]; { standard keys }
ExtKeys = [VK_LEFT, VK_RIGHT]; { extended keys }
fExtended = $01000000; { extended key flag }
begin
Handled := False;
with Msg do
if ((Message > = WM_KEYFIRST) and (Message <= WM_KEYLAST)) and
((wParam in StdKeys) or {$IFDEF VER120}(GetKeyState(VK_CONTROL) < 0) or {$ENDIF}
(wParam in ExtKeys) and ((lParam and fExtended) = fExtended)) then
try
if IsChild(WebBrowser1.Handle, hWnd) then
{ handles all browser related messages }
begin
with WebBrowser1.Application as IOleInPlaceActiveObject do
Handled := TranslateAccelerator(Msg) = S_OK;
if not Handled then
begin
Handled := True;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
except
end;
end;