WINDOWS messaging

zhaozj2021-02-16  73

This project code download // This project involves other transaction processing

July 18, 2004, 17:04:44 ------------------------------ Project: exani_ICON // Dynamic Transform icon Understand Windows Message How to use, for unknown news, you can see it today

MSDN6.0 Winui.chm, this file lists the understanding of many message messages is roughly: two types one: (send message generation motion call a function) ■ That is the same as directly calling a function effect ■ Send a designated by sendMessage or PostMessage Message, then due to the role of the message mechanism

The response function (MFC class library) that will be activated (transfer), such as: SendMessage (wm_seticon, icon_small, (lparam) HiCon; // LResult SendMessage (uint message, wparam wparam = 0, lparam lparam =

0); You can find that sendMessage () has three parameters, where the first is the message to send, and the back two participants

How do we need to determine in practical applications? It is not difficult to find that these two parameters are as response messages.

The function of the function, and usually when the message is activated, the message itself will go to get the function of the function of responding.

The value is given to the function as the entry value of the function, but since the message is artificial, not the system

Produced (hereinafter referred to in the following second article), so you need to send a shape to the message

Sending that actually the statement is equivalent to Seticon (HICON, ICON_SMALL); == (SendMessage (wm_seticon, icon_small, (lparam) HiCon);) So why we will say like this, use seticon () The function can, the driver also uses the message.

Is this function? Yes, it can be called directly, but this is in this example, but sometimes

It is not possible to call directly (because you have no way to call) Please see the following example 2: (Execute a message to generate a message to find a response event) ■ In VB, this step has been encapsulated ■ For example, the user clicks When the button is generated, a WM_COMMAND message will be generated. At this time, the message mechanism will look for

ON_COMMAND (iDR_about, onain) macro finds a function of the corresponding mapping map (customize

Function) If you want to call the onAbout () function here, you can call on the surface, it seems to call OnAbout () because you double-click the button on the dialog resource. Write a button event, but in this project, VC (IDE) has automatically made message mapping for you.

This handler is also our usual event response function, and my understanding is actually a callback function. And this message is an event.

Why is it a callback function?

I have seen someone in the Internet to define the callback function.

The callback function is written by you yourself. You need to call another function, and one of the parameters of this function is your callback function name. In this way, the system will call your callback function when necessary, so you can do what you have to do in the callback function. The caller is turned back to call the caller's function (sufficient bite), so it is called a callback.

So trying, how is Windows know what to call this function? It is known from the message map. How did I find this function?

This question is concerned. So the user needs to tell Windows to the pointer of this function. Although the system is not obvious to you under the CPP file, it has an address.

Register, that is because this registration process has been completed internally by the macro of the message map.

This whole process is to fully meet the definition of the callback function!

转载请注明原文地址:https://www.9cbs.com/read-15375.html

New Post(0)