TWebBrowser控件无法响应回车键

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
TWebBrowser控件无法响应回车键怎么办?希望得到一个很妥当的方法 WnEunfn(斯人不语)
好不容易才解决这个问题,由于代码比较长,你要慢慢看吧……
首先:
uses ActiveX;//引用!!
----------------------------------------------------------------
TfrmChildWeb = class(TForm)
WebBrowser: TWebBrowser;//TwebBrowser!!!
procedure FormCreate(Sender: TObject);//必用的一个事件…
private
FOleInPlaceActiveObject: IOleInPlaceActiveObject;
procedure MsgHandler(var Msg: TMsg; var Handled: Boolean);//自定义的一个处理……
public
end;
----------------------------------------------------------------
过程:
procedure TfrmChildWeb.MsgHandler(var Msg: TMsg; var Handled: Boolean);
var
iOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
if WebBrowser = nil then begin
Handled := False;
Exit;
end;
Handled := (IsDialogMessage(WebBrowser.Handle, Msg) = True);
if (Handled) and (not WebBrowser.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser.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 = VK_BACK) or (Msg.wParam = VK_LEFT) or (Msg.wParam = VK_RIGHT)) then
else
FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;
 
procedure TfrmChildWeb.FormCreate(Sender: TObject);
begin
Application.OnMessage := MsgHandler;
end;
 

Similar threads

后退
顶部