SendMessage is a special message because its parameter return value will be different according to different messages
First, let’s analyze this function
The first parameter HWND hWnd is the handle of the object to which this message is sent. hwnd generally refers to the window handle, but the window here is in a broad sense. A button, a text box, a list box and other controls can all be regarded as buttons, so You can also pass their handles.
The second parameter UINT Msg is the message to be sent. Window messages generally start with WM, which means WindowMessage takes 2 letters, and button messages generally start with BM, which is ButtonMessage, a static class is
STM, the list box is LBM and so on. In short, whatever message you want to send, write it here.
The third and fourth parameters are additional parameters for the message. These two parameters will vary depending on the value of the incoming message.
WPARAM used to be a 16-bit integer or word parameter in 16-bit WINDOWS
LPARAM used to be a 32-bit integer or long parameter in 16-bit WINDOWS
p>At that time, if you want to use LPARAM, you usually need to use HIWORD and LOWORD macros to get the high 16 bits and low 16 bits of LPARAM, because they represent different things.
Now for 32-bit operating systems, there is no difference between them. They are all 32-bit integers. The reason why they did not change the name is probably for the sake of compatibility.
In fact, they are all defined in winuser.h. If you trace the past, you can generally see that they are long type.
The return value of this function will also vary depending on the message sent
For example, when we click a button in the window, the program will put a WM_COMMAND into the program's message queue, so the window can process the WM_COMMAND message
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
WM_COMMAND, // the message to send
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
); p>
This is the description in MSDN. The first one must be the handle of the window, and the second one is the message
The third parameter specifies the notification code and ID of the button
wParam
The high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
The low-order word specifies the identifier of the menu item, control, or accelerator
The high-order word represents the notification code, and the low-order word represents its ID. We Generally, HIWORD and LOWORD are used to separate them
For example, id = LOWORD(wParam) like this
lParam
Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
This represents the handle of the control, which is the handle of the button clicked.
Another example is this:
SendMessage(
(HWND) hWnd, // handle to destination window
BM_GETCHECK, // message to send
(WPARAM) wParam, // not used; must be zero
(LPARAM) lParam // not used; must be zero
);
This BM_GETCHECK message can get whether a check box is checked or not
The first parameter should obviously be the handle of the check box
The first parameter The two parameters are the message
The third and fourth parameters are clearly written in MSDN. If they are not used, they must be written as 0
So when calling, we must clearly write them as
SendMessage(hwndCtrl,BM_GETCHECK,0,0);
And its return value can be the following ones
BST_CHECKED BST_INDETERMINATE BST_UNCHECKED
These are macros defined in winuser.h. They are essentially integers, but it is easier to understand after the macro is defined.
So sometimes we can use an if statement to determine whether it is Not selected
if(BST_CHECKED == SendMessage(hwndCtrl,BM_GETCHECK,0,0))
{
//Write the processing code
}
These things can be found on MSDN, OK, that’s pretty much it
1. Prune once after flower decay, mainly to remove residual flowers, some pests and diseases, too long and weak branches, et