TChromium如何阻止鼠标中键点击链接?

时间:2013-08-07 08:57:35

标签: delphi delphi-xe3 tchromium chromium-embedded

如何阻止鼠标中键点击TChromium中的链接?
我想用自己的鼠标点击鼠标来在新标签中打开它,所以我需要在TChromium中阻止鼠标中键,然后勾住鼠标中键,然后在新标签页中打开所选链接。
我有这个默认功能:

function TCustomRenderProcessHandler.OnBeforeNavigation(const browser: ICefBrowser;
  const frame: ICefFrame; const request: ICefRequest;
  navigationType: TCefNavigationType; isRedirect: Boolean): Boolean;
begin
  Result:=False;
end;

但它确实没有给予任何东西 TNX

1 个答案:

答案 0 :(得分:1)

我是用另一种方式做到的 @TLama,感谢快速工作的Hook功能。
那么,我是怎么做到的:

    //@HOOK PROC
    function MouseProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
    var
      HookStruct: TMouseHookStruct;
    begin
      HookStruct := PMouseHookStruct(lParam)^;

      if (nCode >= 0) then
      begin
        case wParam of
          WM_MBUTTONDOWN:
            Begin
              MiddleDown := True;
              LeftMouse := False;
            End;

          WM_LBUTTONDOWN:
            Begin
              MiddleDown := False;
              LeftMouse := True;
            End;

          WM_RBUTTONDOWN:
            Begin
              MiddleDown := False;
              LeftMouse := False;
            End;
        end;
      end;

      Result := CallNextHookEx(0, nCode, wParam, lParam);
    end;

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      If(MiddleDown) then
        Begin
          MiddleDown:=False;
          If(SelectedItem<>'') Then
            Form1.AddNewTab(SelectedItem,SelectedItem,'');
        End
      Else If(LeftMouse) then
        Begin
          LeftMouse:=False;
          If(SelectedItem<>'') Then
            FBrowsers[Current_FBrowser_Index].Load(SelectedItem);
        End;
    end;

function TCustomRenderProcessHandler.OnBeforeNavigation(const browser: ICefBrowser;
  const frame: ICefFrame; const request: ICefRequest;
  navigationType: TCefNavigationType; isRedirect: Boolean): Boolean;
begin

  if navigationType = NAVIGATION_LINK_CLICKED then
  begin
    Result := True;
  end
  else
    Result := False;
end;

那么,那就是它在我的DCEF3中是如何工作的:) 感谢所有人的帮助!!!