如何截留第三方组件(OCX)的键盘、鼠标操作? 我的程序需调用第三方的组件,但又想屏蔽该组件一些功能,如快捷键、鼠标右键这类。。多谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用Application.OnMessage或者用Application.HookMainWindow来截获消息 测试过用Application.OnMessage方法,当第三方ActiveX组件被激活后,拦截就无效了。 //... 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;//... 同ACTIVEX激不激活有什么关系?所有消息都是先到应用程序,再由应用程序传到ACTIVEX。。只要拦住消息就行了。 //对不起,还是搞不定,请帮忙看看unit Unit1;interfaceuses 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. //重发一次测试,在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; inheritedend;procedure TForm1.FormCreate(Sender: TObject);begin Pdf1.src := 'http://192.168.0.48/abc.pdf'; pdf1.Show;end;end. ……我是说修改:PdfLib_TLB.pas中的TPdf,不是TForm1 刚想告诉你,我知错了。后来改了PdfLib_TLB.pas文件,但是还是不行。 写拨号程序时,use RAS, 但是编译时提RAS.DCU找不到。 图片移动问题! DXDBGRID 关于delphi的TDBChart 什么情况下产生EinvalidPointer异常 Delphi如何操作XML节点的添加修改删除并显示到程序做为菜单使用 如何用键盘钩子截获键盘动作(击键动作)??? 怎样自动查找DBLISTBOX中的内容 请问如何在局域网中如何实现ip地址到主机名的转换? 关于jpeg文件的一些问题,高手进来看看!!! 请问Response的sendStream方法和属性ContentStream 关于TPdf不能第二次打开*.pdf的文件?
或者用
Application.HookMainWindow来截获消息
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;
//...
所有消息都是先到应用程序,再由应用程序传到ACTIVEX。。
只要拦住消息就行了。
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.
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.
我是说修改:PdfLib_TLB.pas中的TPdf,不是TForm1
后来改了PdfLib_TLB.pas文件,但是还是不行。