delphi – FireMonkey等同于Application.OnMessage?
发布时间:2020-12-15 09:40:03 所属栏目:大数据 来源:网络整理
导读:使用Delphi Win32(VCL)我使用: Application.OnMessage := MyAppMessage; FireMonkey中的等价物是什么? 我有一个例程,需要捕获应用程序中的所有键盘和鼠标事件(在所有活动的窗体控件上)并处理它们. 解决方法 我不知道在FireMonkey中以平台无关的方式在应用
使用Delphi Win32(VCL)我使用:
Application.OnMessage := MyAppMessage; FireMonkey中的等价物是什么? 我有一个例程,需要捕获应用程序中的所有键盘和鼠标事件(在所有活动的窗体控件上)并处理它们. 解决方法
我不知道在FireMonkey中以平台无关的方式在应用程序级捕获鼠标和键盘事件的方法.从Delphi XE 2 Update 2开始,我认为还没有实现.
但是,默认情况下,FireMonkey表单会在控件执行之前获取所有MouseDown和KeyDown事件. 如果您只是覆盖表单上的MouseDown和KeyDown事件,您将完成同样的事情. type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; private { Private declarations } public { Public declarations } procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,Y: Single); override; procedure KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState); override; end; { TForm1 } procedure TForm1.KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState); begin // Do what you need to do here ShowMessage('Key Down'); // Let it pass on to the form and control inherited; end; procedure TForm1.MouseDown(Button: TMouseButton; Shift: TShiftState; X,Y: Single); begin // Do what you need to do here ShowMessage('Mouse Down'); // Let it pass on to the form and control inherited; end; 如果需要,可以继续使用MouseMove,MouseUp,MouseWheel,MouseLeave,KeyUp,DragEnter,DragOver,DragDrop和DragLeave. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |