本文整理自网络,侵删。
增加一个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 }
beginHandled := 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;
相关阅读 >>
更多相关阅读请进入《Delphi》频道 >>