Is FireMonkey equivalent to Application.OnMessage?

With Delphi Win32 (VCL) I use:

Application.OnMessage := MyAppMessage; 

What is the equivalent in FireMonkey?

I have a program that should catch all the keyboard and mouse events in the application (on all active elements of the form) and process them.

+4
source share
3 answers

In FireMonkey, I don't know how to capture mouse and keyboard events at the application level agnostically. I do not think that this has been implemented yet, as from Delphi XE 2 Update 2.

However, by default, FireMonkey forms receive all MouseDown and KeyDown events before the actions of the controls are executed.

If you just override the MouseDown and KeyDown events in your form, you will do the same.

 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; 

If you want, you can continue to work with MouseMove, MouseUp, MouseWheel, MouseLeave, KeyUp, DragEnter, DragOver, DragDrop and DragLeave.

+5
source

FireMonkey is a cross-platform platform and runs on Windows, Mac OSX, iOS and, no doubt, many other platforms over time. Therefore, there are no Windows messages in FireMonkey.

Whatever you do with OnMessage in VCL most likely has an equivalent in FireMonkey. That this equivalent is highly dependent on what your OnMessage handler is trying to achieve.

+6
source

These answers are suitable for open events, but for other obscure system events this is more complicated. At the time of this writing, there was no answer:

capturing-usb-plug-unplug-events-in-firemonkey

but this will help solve the general problem.


I would post this as a comment, not an answer, but the previous answers did not accept further comments.

0
source

Source: https://habr.com/ru/post/1380274/


All Articles