With Delphi Win32 (VCL) I use:
Application.OnMessage := MyAppMessage;
What is the equivalent in FireMonkey?
I have a routine that needs to catch all the keyboard and mouse events in the application (on all the active form controls) and handle them.
I don't know of a way in FireMonkey to capture mouse and keyboard events at the application level in a platform agnostic way. I don't think that has been implemented yet, as of Delphi XE 2 Update 2.
However, by default FireMonkey forms get all of the MouseDown and KeyDown events before the controls do.
If you simply override the MouseDown and KeyDown events on your form, you'll accomplish the same thing.
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 keep going with MouseMove, MouseUp, MouseWheel, MouseLeave, KeyUp, DragEnter, DragOver, DragDrop, and DragLeave.
FireMonkey is cross platform and runs on Windows, Mac OSX, iOS and no doubt many other platforms in due course. Therefore there are no Windows messages exposed by FireMonkey.
Whatever it is you are used to doing with OnMessage
in the VCL most likely has an equivalent in FireMonkey. Exactly what that equivalent is depends very much on what your OnMessage
handler is trying to achieve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With