In Delphi xe7 program development, the message mechanism ensures inter-process communication.
In the program, the message comes from:
1) system: notifies your program users of input, painting, and other system-wide events;
2) Your program: communication information between different program parts.
When to use messages?
When you write a program, you usually use events instead of messages. The control triggers events for you to process, while the internal control processes the events through the message mechanism (transparent to you ), to achieve communication with other controls and process system information.
No matter what, sometimes you do need to use messages.
- Your program must respond to events not defined by a system or framework (or events not exposed)
- You have created a control that needs to communicate with other programs.
- Create a multi-threaded program and use messages for communication between different threads
How do I select a message solution?
When you use a rad Studio development project, you can use two message processor systems, depending on the framework of your program:
- The firemonkey program must use a cross-platform message processing mechanism, using RTL;
- The VCL program depends on the Message Processing Mechanism of Windows API.
When you write a control by yourself, you may need to decide the message mechanism based on the platform you are using, whether to use FMX or VCL. In either case, VCL uses the Windows message mechanism, just as the existing VCL control sends and receives messages through the windows API, in addition, the VCL framework does not replace the message translation of Windows APIs with the FMX cross-platform mechanism.
Conclusion:
- Delphi xe7 supports the cross-platform Message Processing Mechanism RTL;
- When developing a native VCL program, you need to use Windows API messages.
Messages in Delphi xe7