DELPHI Webbrowser 响应回车键(EWB响应正常,无需额外代码)

2016-11-09 22:40:40来源:CSDN作者:xhh2001人点击

第七城市

增加一个ApplicationEvents,在Message事件中如下代码(WB看自己的WEBBROWSER 控件命名)


procedure TFrmMain.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);      //专为IE内核 WEBBROWSER 响应回车键


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(WB.Handle,   hWnd)   then
       {   handles   all   browser   related   messages   }
        begin
          with  WB.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;


第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台