1

How to block middle mouse click on the links in TChromium?
I want to handle this middle mouse click by my own to open it in new tab, so i need to block this middle mouse click in TChromium, and then hook middle mouse, and then open selected link in new tab.
I have this default function:

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

But exactly it gives nothing.
TNX

4

1 回答 1

1

我用另一种方式做到了。
@TLama,感谢快速工作的钩子函数。
所以,我是怎么做到的:

    //@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 中的工作方式 :)
感谢大家的帮助!!!

于 2013-08-07T14:01:53.903 回答