The message processing in Delphi

Source: Internet
Author: User

1. Windows message-driven system

In Windows systems, messaging is the primary means of achieving communication and control in the country. The frontal system works in a message-driven manner. In the system, the user input operation, the display information change, the system environment parameter change and so on all time are in the System Definition message form in the related application and the window. So the main task of programming is to design code for the processing of these messages.

In an application, the sender can request the recipient to complete the appropriate processing by sending a message. When the program is running, the Windows system establishes a message queue for each instance of the application, a message that is sent to the instance of the program, a message loop is set in the master part of the application, and a set of system functions is used to read and parse the message sequentially from the message queue of the program instance. and send them to the specified message. This message delivery can use system-defined messages or user-defined messages. Many of the existing visual development environments have encapsulated this process into the various classes, parts, and methods of the components.

When we use them to write an application, we must consider what each object will do, decompose them into different message handlers, and correspond to different messages. Although there are a wide variety of controls (parts), it is very convenient to write programs. But these are some common objects and message handlers, and if we're going to write our own parts or want to be more flexible with our existing controls, we need to have a deep understanding of message-driven systems and the mapping of messages, the writing of message-handling functions, and the system's functions for message operations.

2, Delphi development Environment:

Delphi has become an increasingly popular 32-bit Windows development environment, one of the biggest features in Delphi can be customized messages to write their own widget (cmponent), because the writing artifacts generally to the corresponding message processing.

3, Delphi in the message:

All classes in Delphi have a built-in mechanism for processing messages and invoking message processing. VCL defines a messaging system that sends all Windows messages, including custom messages, and you only need to establish a message handling method. A Windows message is a data record that contains more than one field. The most important of these is the message identity, which has many messages defined in Windows. Other useful fields are two parameters and one result field. A 16-bit and a 32-bit parameter Wparan record data type:

type
TMessage = packed record
Msg: Cardinal;
case Integer of
0: (
WParam: Longint;
LParam: Longint;
Result: Longint);
1: (
WParamLo: Word;
WParamHi: Word;
LParamLo: Word;
LParamHi: Word;
esultLo: Word;
ResultHi: Word);
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.