Windows Message Processing Mechanism and VB

Source: Internet
Author: User

Before starting a detailed description of VB, the tutorial of Jilin University described the Message Processing Mechanism in windows and briefly described the Message Processing Mechanism in Windows using the C language: register the window class, create a window, display the message loop, retrieve and send the window, and execute the function.

To be honest, I didn't quite understand it. Later I found some materials and probably understood what WINDOWS Message Processing Mechanism was like.


First, let's talk about the message. The message is a key part of any object-oriented system. The interaction between the Windows environment and the application, and the interaction with the outside world are completed through the message. A notification sent by Windows tells the application that something has happened. For example, if you click the mouse, change the window size, or press a key on the keyboard, Windows will send a message to the application. The message itself is passed to the application as a record, which contains the Message Type and other information.

 

 

Windows message system consists of three parts:

 

Message Queue: Windows maintains a message queue for all registered applications. The application must obtain from the message queue.

Message, and then distributed to a window.

Message loop: The application retrieves a message from the Message Queue through this loop mechanism, and then assigns it to an appropriate window. However

Then, retrieve the next message from the message queue and assign it to the appropriate window.

Window Process: each window has a window process to receive messages sent to the window. Its task is to get the message and then

In response, the window process is a callback function. After processing a message, it usually returns a value to Windows.

Note that a callback function is a function in a program that is called by a Windows or external module.


There are five steps for a message to be responded by a window from generation to generation:


1) An event occurs in the system.

2) Windows translates the event into a message and puts it in the message queue.

3) The application receives the message from the message queue and stores it in records.

4) The Window process in which the application sends messages to an appropriate window.

5) The Window Process responds to the message and processes it.


Steps 3 and 4 constitute the message loop of the application. Message loops are often the core of Windows applications, because message Loops

Enables an application to respond to external events. The task of message loop is to retrieve messages from the message queue and pass the messages to the appropriate window. If there are no messages in the message queue, Windows allows other applications to process their messages.

The biggest feature of Windows is its graphical operation interface, which is based on its message processing mechanism.


If you do not understand the WINDOWS Message Processing Mechanism, you certainly cannot fully understand windows programming. Unfortunately, I still have a relatively low understanding of the internal principles of WINDOWS Message Processing Mechanism.



Reference: Jilin University Tutorial: Baidu encyclopedia Langfang Normal University-library-chinnet-use Windows message mechanism in VB

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.