Hallo,
Sollte so funktionieren:
// aktiven Browser ermitteln:
Delphi-Quellcode:
function TForm1.GetCurrentWB: TWebbrowser;
begin
Result := nil;
with PageControl do
if ActivePage.Controls[0] is TWebbrowser then
Result := (TWebbrowser(ActivePage.Controls[0]));
end;
procedure TForm1.MsgHandler(var Msg: TMsg; var Handled: Boolean);
const
StdKeys = [VK_BACK, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT];
var
IOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
CurrentWB: TWebbrowser;
begin
CurrentWB := GetCurrentWB;
if CurrentWB = nil then
begin
Handled := False;
Exit;
end;
Handled := (IsDialogMessage(CurrentWB.Handle, Msg) = True);
if (Handled) and (not CurrentWB.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := CurrentWB.Application;
if Dispatch <> nil then
begin
Dispatch.QueryInterface(IOleInPlaceActiveObject, IOIPAO);
if IOIPAO <> nil then FOleInPlaceActiveObject := IOIPAO;
end;
end;
if FOleInPlaceActiveObject <> nil then
if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
(Msg.wParam in StdKeys) then
//nothing - do not pass on Backspace, Left, Right, Up, Down arrows
else FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
Man könnte auch den aktiven Browser im OnChange des PageControls auslesen und in einer Variable (FCurrentWB) speichern.
Delphi-Quellcode:
procedure TForm1.PageControl1Change(Sender: TObject);
begin
FCurrentWB := GetCurrentWB;
end;