Hallo
Setze die Komponente TApplicationEvents auf die Form und weise ihr einen OnMessage Handler zu.
Delphi-Quellcode:
uses
ActiveX;
procedure TForm1.ApplicationEvents1Message(
var Msg: tagMSG;
var Handled: Boolean);
const
StdKeys = [VK_TAB, VK_RETURN];
{ standard keys }
ExtKeys = [VK_DELETE, VK_BACK, VK_LEFT, VK_RIGHT];
{ extended keys }
fExtended = $01000000;
{ extended key flag }
var
CurrentWB: TWebbrowser;
begin
CurrentWB := Webbrowser1;
if not Assigned(CurrentWB.Document)
then
begin
Handled := False;
Exit;
end;
if IsChild(CurrentWB.Handle, Msg.Hwnd)
then
begin
if (Msg.
Message = WM_CLOSE)
then
msg.
message := 0
else
if ((Msg.
Message >= WM_KEYFIRST)
and (Msg.
Message <= WM_KEYLAST))
and
((Msg.wParam
in StdKeys)
or (GetKeyState(VK_CONTROL) < 0)
or
(Msg.wParam
in ExtKeys)
and ((Msg.lParam
and fExtended) = fExtended))
then
begin
Handled := (CurrentWB.Application
as IOleInPlaceActiveObject).TranslateAccelerator(Msg) = S_OK;
if not Handled
then
begin
Handled := True;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end;
end;