Delphi What does the OnMessage Event in DelphiVCL.Application do?

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
What does the OnMessage Event in DelphiVCL.Application do?
By Muhammad Azizul Hakim January 24, 2022

In Для просмотра ссылки Войди или Зарегистрируйся the OnMessage or DelphiVCL.Application.OnMessage occurs when the application receives a message from either the Windows operating system or another application.

How to use the DelphiVCL.Application.OnMessage event properly?​

We use the OnMessage to trap any or all Windows messages posted to all windows in the application. The OnMessage event occurs when an application receives a Windows message. An OnMessage event handler allows an application to respond to messages other than those declared in the events for TApplication. If the application does not have a specific handler for an incoming message, the message is dispatched to the window for which it was intended, and Windows handles the message.

Note: OnMessage only receives messages that are posted to the message queue, not those sent directly with the Windows API SendMessage function.

Caution: Thousands of messages per second flow through this event. Be careful when coding the handler, because it can affect the performance of the entire application.
Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.

How do I examine the properties and methods of the DelphiVCL.Application.OnMessage event?

Let’s browse all the properties, methods, and built-in properties of the DelphiVCL.Application.OnMessage using the dir() command:
Python:
import DelphiVCL
 
dir(DelphiVCL.Application.OnMessage)
See the responses in our Windows command prompt:
1643008601843.png
You can also read short information about the DelphiVCL.Application.OnMessage using the print() command:
Python:
print(DelphiVCL.Application.OnMessage)
print(DelphiVCL.Application.OnMessage.__doc__)
See the responses in our Windows command prompt:
1643008639852.png