我的程序需调用第三方的组件,但又想屏蔽该组件一些功能,如快捷键、鼠标右键这类。。
多谢

解决方案 »

  1.   

    用Application.OnMessage
    或者用
    Application.HookMainWindow来截获消息
      

  2.   

    测试过用Application.OnMessage方法,当第三方ActiveX组件被激活后,拦截就无效了。
      

  3.   

    //...
      Txxx = class(TOleControl)
    //...
      protected
        procedure WndProc(var Message: TMessage); override;
    //...
      end;//...
    procedure Txxx.WndProc(var Message: TMessage);
    begin
      case Message.Msg of
        WM_RBUTTONDOWN: Message.Result := 0;
      else inherited;
      end;
    end;
    //...
      

  4.   

    同ACTIVEX激不激活有什么关系?
    所有消息都是先到应用程序,再由应用程序传到ACTIVEX。。
    只要拦住消息就行了。
      

  5.   

    //对不起,还是搞不定,请帮忙看看
    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleCtrls, ExtCtrls,PdfLib_TLB;type
      TForm1 = class(TForm)
        PDF1: TPdf;
      protected
        procedure WndProc(var Message: TMessage); override;
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}procedure TForm1.WndProc(var Message: TMessage);
    begin
      case Message.Msg of
        WM_RBUTTONDOWN:
        begin
            Showmessage('右键');
            Message.Result := 0;
        end;
        VK_F1:
        begin
            Showmessage('F1');
            Message.Result := 0;
        end;
      else inherited;
      end;
    end;
    end.
      

  6.   

    //重发一次测试,在PDF组件,依然无法截取按键
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, OleCtrls, PdfLib_TLB;type
      TForm1 = class(TForm)
        Pdf1: TPdf;
        procedure FormCreate(Sender: TObject);
    protected
        procedure WndProc(var Message: TMessage); override;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WndProc(var Message: TMessage);
    begin
      if Message.Msg = WM_RBUTTONDOWN then
      begin
        ShowMessage('右键');
        Message.Result := 0;
        Exit;
      end;  if Message.WParam = VK_F1 then
      begin
        ShowMessage('F1');
        Message.Result := 0;
        Exit;
      end;  inherited
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Pdf1.src := 'http://192.168.0.48/abc.pdf';
      pdf1.Show;
    end;end.
      

  7.   

    ……
    我是说修改:PdfLib_TLB.pas中的TPdf,不是TForm1
      

  8.   

    刚想告诉你,我知错了。
    后来改了PdfLib_TLB.pas文件,但是还是不行。