The difference between SendMessage and PostMessage
PostMessage is only responsible for putting messages into the message queue, not determining when and whether to process SendMessage to wait until the return code (DWORD type) is processed by the message to continue postmessage immediately after execution returns SendMessage must wait until the message is processed Before returning.
the difference between SendMessage and PostMessage
1, the first is the difference between the meaning of the return value, we first look at the MSDN statement: LRESULT SendMessage ( hwnd hwnd, UINT Msg, WPARAM WPARAM, LPARAM LPARAM ); BOOL PostMessage ( hwnd hwnd, UINT Msg, WPARAM WPARAM, LPARAM LPARAM ); The meaning of the 4 parameters is the same, the return value type is different (in fact, from the data they are a 32-bit number, but the meaning is not the same), LRESULT represents the message is processed after the return value, BOOL indicates that the message is not a successful post. 2, PostMessage is asynchronous, SendMessage is synchronous. PostMessage only put the message in the queue, regardless of whether the message is processed to return, the message may not be processed, and SendMessage wait for the message to be processed before returning, if the message is not processed, the thread that sent the message will always be blocked. 3, if within the same thread, SendMessage send message, by USER32. The DLL module invokes the message handler for the target window and returns the result. SendMessage sends a message in the same thread and does not enter the thread message queue. When PostMessage sends a message, the message is first placed in the thread's message queue and then dispatched to the target window (dispatchmessage) through the message loop. If within a different thread, SendMessage sends a message to the destination window that belongs to the thread's message queue, and then sends the message to the thread in USER32. The DLL module monitors and waits for message processing until the target window finishes processing the return. SendMessage also did a lot of work before returning, such as responding to other threads SendMessage it. When you Post to another thread, it is best to use postthreadmessage instead of Postmessage,postmessage's hWnd parameter to be NULL, equivalent to PostThreadMessage + Getcurren Tthreadid. When you Post wm_quit, you should use PostQuitMessage instead. 4, the system only to reorganize (marshal) system messages (0 to wm_user messages), send user messages (Wm_user above) to other processes, need to do their own integration. When sending system messages with PostMessage, SendNotifyMessage, Sendmessagecallback, and other asynchronous functions, pointers cannot be used in parameters because the sender does not wait for the message to be processed and the recipient has not yet processed the pointer and has been freed. 5, in Windows 2000/xp, each message queue can only hold up to 10,000 Post messages, more than the not processed will not be processed, directly discarded. This value can be changed to a larger size: [hkey_local_machine/software/microsoft/windows nt/currentversion/windows] userpostmessagelimit, the minimum can be 4000 |
SendMessage parameter Daquan
Windows is a message-driven system, and SendMessage is one of the main means of messaging between applications and applications, where I've compiled detailed parameter descriptions for SendMessage functions for personal use.
LRESULT SendMessage (
HWND hwnd, UINT Msg, WPARAM WPARAM, LPARAM LPARAM);
The parameter 1:hwnd-the window handle. A window can be any type of screen object.
The parameter 2:wmsg-is used to distinguish constant values from other messages.
The parameter 3:wparam-is usually a constant value associated with a message, or a handle to a window or control.
The parameter 4:lparam-is usually a pointer to the in-memory data.
Wmsg parameter constant value:
#DeFine wm_create 0x01
Create a window
#DeFine Wm_destroy 0x02
Send when a window is broken
#DeFine Wm_move 0x03
Move a window
#DeFine wm_size 0x05
Change the size of a window
#DeFine wm_activate 0x06
A window is activated or inactive
#DeFine Wm_setfocus 0x07
One window gets focus
#DeFine Wm_killfocus 0x08
A window loses focus
#DeFine wm_enable 0x0A
A window changes to the Enable state
#DeFine Wm_setredraw 0x0B
Sets whether the window can be redrawn
#DeFine Wm_settext 0x0C
The application sends this message to set the text of a window
#DeFine Wm_gettext 0x0D
The application sends this message to copy the corresponding window's text to the buffer
#DeFine Wm_gettextlength 0x0E
Gets the length of the text associated with a window (does not contain null characters)
#DeFine WM_PAINT 0x0F
Ask for a window to repaint itself
#DeFine Wm_close 0x10
Send a signal when a window or application is about to close
#DeFine wm_queryendsession 0x11
When the user chooses the End dialog box or the program calls the ExitWindows function itself
#DeFine Wm_quit 0x12
Used to end a program run
#DeFine Wm_queryopen 0x13
Sends this message to an icon when the user window restores the previous size position
#DeFine WM_ERASEBKGND 0x14
When the window background must be erased (example when the window changes size)
#DeFine Wm_syscolorchange 0x15
Send this message to all top-level windows when the system color changes
#DeFine wm_endsession 0x16
When the system process issues a WM_QUERYENDSESSION message, the message is sent to the application informing it that the conversation is over
#DeFine Wm_showwindow 0x18
When the hidden or displayed window is sent this message to this window
#DeFine Wm_activateapp 0x1C
Send this message to the application which window is active and which is inactive
#DeFine Wm_fontchange 0x1D
This message is sent to all top-level windows when the system's font repository changes
#DeFine Wm_timechange 0x1E
Send this message to all top-level windows when the system's time changes
#DeFine Wm_cancelmode 0x1F
Send this message to cancel an in-progress state (operation)
#DeFine wm_setcursor 0x20
If the mouse causes the cursor to move through a window and the mouse input is not captured, a message is sent to a window
#DeFine wm_mouseactivate 0x21
When the cursor is in a non-activated window and the user is pressing a key on the mouse to send this message to the current window
#DeFine wm_childactivate 0x22
Send this message to the MDI child window when the user clicks the title bar of this window, or when the window is activated, moves, changes the size
#DeFine Wm_queuesync 0x23
This message is sent by a computer-based training program that separates the user input message from the Wh_journalpalyback hook program
#DeFine Wm_getminmaxinfo 0x24
This message is sent to the window when it is going to change size or position
#DeFine Wm_painticon 0x26
Send to minimized window when its icon is going to be redrawn
#DeFine Wm_iconerasebkgnd 0x27
This message is sent to a minimized window only if it's background must be redrawn before drawing the icon
#DeFine Wm_nextdlgctl 0x28
Send this message to a dialog box program to change the focus position
#DeFine Wm_spoolerstatus 0x2A
This message is emitted whenever a print management queue increases or decreases a job
#DeFine Wm_drawitem 0x2B
Send when the visual appearance of the Button,combobox,listbox,menu changes
#DeFine Wm_measureitem 0x2C
When button, combo box, list box, List View control, or menu item is created
#DeFine Wm_vkeytoitem 0x2e
This message has a lbs_wantkeyboardinput style issued to its owner in response to the WM_KEYDOWN message
#DeFine Wm_chartoitem 0x2F
This message is sent by a lbs_wantkeyboardinput-style list box to his owner in response to the WM_CHAR message
#DeFine Wm_setfont 0x30
The program sends this message when the text is drawn to get the color of the control to be used
#DeFine Wm_getfont 0x31
The application sends this message to get the font of the current control drawing text
#DeFine Wm_sethotkey 0x32
The application sends this message to have a window associated with a hotkey
#DeFine Wm_gethotkey 0x33
The application sends this message to determine if a hot key is associated with a window
#DeFine Wm_querydragicon 0x37
This message is sent to the minimized window, and when the window is about to be dragged and the icon is not defined in its class, the application can return an icon or a handle to the cursor, which is displayed when the user drags and puts the icon
#DeFine Wm_compareitem 0x39
Send this message to determine the relative position of the newly added item in the ComboBox or ListBox
#DeFine wm_compacting 0x41
Display memory is very low.
#DeFine wm_windowposchanging 0x46
Call the SetWindowPos function or other window management function when sending this message to the size and position of the window that will be changed
#DeFine wm_windowposchanged 0x47
Call the SetWindowPos function or other window management function when sending this message to the size and position of the window that has been changed
#DeFine Wm_power 0x48
This message is sent when the system is about to enter a paused state
#DeFine Wm_copydata 0x4A
This message is sent when an application passes data to another application
#DeFine Wm_canceljourna 0x4B
When a user cancels the program Log activation state, the message is submitted to the program
#DeFine wm_notify 0x4E
Sends this message to its parent window when an event for a control has already occurred or if the control needs to get some information
#DeFine Wm_inputlangchangerequest 0x50
When the user chooses an input language, or the hotkey of the input language changes
#DeFine Wm_inputlangchange 0x51
Send this message to the affected top-level window when the platform site has been changed
#DeFine Wm_tcard 0x52
Send this message to the application when the program has initialized the Windows Help routine
#DeFine Wm_help 0x53
This message shows that the user pressed the F1, if a menu is active, send this message a menu associated with this window, otherwise it will be sent to the focus window, if there is currently no focus, send this message to the currently activated window
#DeFine wm_userchanged 0x54
When the user has logged in or exited to send this message to all windows, when the user login or exit the system updates the user's specific settings information, the system will send this message as soon as the user updates the settings
#DeFine Wm_notifyformat 0x55
Common controls, custom controls, and their parent window use this message to determine whether a control is using an ANSI or Unicode structure
#DeFine wm_contextmenu??
This message is sent to this window when the user clicks the right button in a window
#DeFine wm_stylechanging 0x7C
This message is sent to the window when the call to the SetWindowLong function will change the style of one or more windows
#DeFine wm_stylechanged 0x7d
When you call the SetWindowLong function one or more window styles, send this message to that window
#DeFine Wm_displaychange 0x7E
Send this message to all windows when the resolution of the monitor changes
#DeFine Wm_geticon 0x7F
This message is sent to a window to return a handle to a large icon or small icon attached to a window
#DeFine Wm_seticon 0x80
The program sends this message to have a new large icon or small icon associated with a window
#DeFine wm_nccreate 0x81
When a window is first created, this message is sent before the WM_CREATE message is sent
#DeFine Wm_ncdestroy 0x82
This message notifies a window that the non-client area is being destroyed
#DeFine wm_nccalcsize 0x83
This message is sent when the customer area of a window must be accounted for
#DeFine wm_nchittest 0x84
Occurs when you move the mouse, hold or release the mouse
#DeFine Wm_ncpaint 0x85
The program sends this message to a window when it (the window) 's frame must be drawn
#DeFine wm_ncactivate 0x86
This message is sent to a window only if its non-client area needs to be changed to show whether it is active or inactive
#DeFine Wm_getdlgcode 0x87
Send this message to a control associated with a dialog box program, widdows the control azimuth key and TAB key to enter this control through the
#DeFine Wm_ncmousemove 0xA0
Send this message to the non-client area of the window when the cursor is moved within the non-client area of a window: the title bar of the form and the border body of the window
#DeFine Wm_nclbuttondown 0xa1
Submits this message when the cursor presses the left mouse button at the same time in the non-client area of a window
#DeFine Wm_nclbuttonup 0xa2
This message is sent when the user releases the left mouse button while the cursor is in a window in non-client area 10
#DeFine WM_NCLBUTTONDBLCLK 0xa3
This message is sent when the user double-clicks the left mouse button while the cursor is in a non-client area 10
#DeFine Wm_ncrbuttondown 0xa4
This message is sent when the user presses the right mouse button while the cursor is in the non-client area of the window
#DeFine Wm_ncrbuttonup 0xa5
This message is sent when the user releases the right mouse button while the cursor is in the non-client area of the window
#DeFine WM_NCRBUTTONDBLCLK 0xa6
This message is sent when the user double-clicks the right mouse button while the cursor is in the non-client area 10
#DeFine Wm_ncmbuttondown 0xa7
This message is sent when the user presses the middle mouse button while the cursor is in the non-client area of the window
#DeFine Wm_ncmbuttonup 0xa8
This message is sent when the user releases the middle mouse button while the cursor is in the non-client area of the window
#DeFine WM_NCMBUTTONDBLCLK 0xa9
This message is sent when the user double-clicks the middle mouse button while the cursor is in the non-client area of the window
#DeFine Wm_keyfirst 0x100
Wm_keydown Press a key
#DeFine Wm_keyup 0x101
Release a key
#DeFine WM_CHAR 0x102
Press a key and have issued WM_KEYDOWN, WM_KEYUP message
#DeFine Wm_deadchar 0x103
Send this message to the window with focus when translating wm_keyup messages with the TranslateMessage function
#DeFine Wm_syskeydown 0x104
Submits this message to the window that has focus when the user presses the ALT key while pressing another key
#DeFine Wm_syskeyup 0x105
Submits this message to the window that has focus when the user releases a key while the ALT key is still pressed
#DeFine Wm_syschar 0x106
When the Wm_syskeydown message is translated by the TranslateMessage function, the message is submitted to the window that has the focus
#DeFine Wm_sysdeadchar 0x107
Send this message to the window with focus when the Wm_syskeydown message is translated by the TranslateMessage function
#DeFine Wm_initdialog 0x110
Sends this message to a dialog box before it is displayed, typically using this message to initialize the control and perform other tasks
#DeFine Wm_command 0x111
When a user selects a menu command item or when a control sends a message to its parent window, a shortcut key is translated
#DeFine Wm_syscommand 0x112
The window receives this message when the user chooses a command on the Window menu or when the user chooses to maximize or minimize
#DeFine Wm_timer 0x113
A timer event has occurred
#DeFine Wm_hscroll 0x114
When a window standard horizontal scrollbar produces a scrolling event, this message is sent to that window and also to the control that owns it
#DeFine Wm_vscroll 0x115
When a window standard vertical scrollbar produces a scrolling event, this message is sent to that window, which is also sent to the control that owns it
#DeFine Wm_initmenu 0x116
This message is sent when a menu is about to be activated, it occurs on an item in the user's menu bar, or a menu key is pressed, which allows the program to change the menu before it is displayed
#DeFine Wm_initmenupopup 0x117
This message is sent when a drop-down menu or submenu is about to be activated, allowing the program to change the menu before it is displayed, without changing all
#DeFine Wm_menuselect 0x11f
Send this message to the owner of the menu (typically a window) when the user selects a menu item
#DeFine Wm_menuchar 0x120
When the menu has been activated the user presses a key (unlike the accelerator key) and sends this message to the owner of the menu
#DeFine Wm_enteridle 0x121
Sends this message to its owner when a modal dialog box or menu enters an empty state, and a modal dialog box or menu enters an empty state, which waits in the queue without a message after processing one or several previous messages
#DeFine Wm_ctlcolormsgbox 0x132
Send this message to the owner window of the message box before Windows draws the message box, and in response to this message, the owner window can set the text and background color of the message box by using the handle of the given related display device
#DeFine Wm_ctlcoloredit 0x133
When an edit control is about to be drawn when this message is sent to its parent window by responding to this message, the owner window can set the text and background color of the edit box by using the handle of the given related display device
#DeFine Wm_ctlcolorlistbox 0x134
When a ListBox control is going to be drawn before sending this message to its parent window by responding to this message, the owner window can set the text and background color of the list box by using the handle of the given related display device
#DeFine wm_ctlcolorbtn 0x135
When a button control is about to be drawn when this message is sent to its parent window by responding to this message, the owner window can set the button's text and background color by using the handle of the given related display device
#DeFine Wm_ctlcolordlg 0x136
When a dialog box control is going to be drawn before sending this message to its parent window by responding to this message, the owner window can set the text background color of the dialog box by using the handle of the given related display device
#DeFine Wm_ctlcolorscrollbar 0x137
When a scrollbar control is about to be drawn when this message is sent to its parent window by responding to this message, the owner window can set the background color of the scroll bar by using the handle of the given related display device
#DeFine wm_ctlcolorstatic 0x138
When a static control is about to be drawn when this message is sent to its parent window by responding to this message, the owner window can set the text and background color of the static control by using the handle of the given related display device
#DeFine Wm_mousefirst 0x200
Occurs when the mouse is moved
#DeFine Wm_mousemove 0x200
Occurs when moving the mouse, same as Wm_mousefirst
#DeFine Wm_lbuttondown 0x201
Press the left mouse button
#DeFine Wm_lbuttonup 0x202
Release left mouse button
#DeFine WM_LBUTTONDBLCLK 0x203
Double click left mouse button
#DeFine Wm_rbuttondown 0x204
Press the right mouse button
#DeFine Wm_rbuttonup 0x205
Release the right mouse button
#DeFine WM_RBUTTONDBLCLK 0x206
Double-click the right mouse button
#DeFine Wm_mbuttondown 0x207
Press the middle mouse button
#DeFine Wm_mbuttonup 0x208
Release middle mouse button
#DeFine WM_MBUTTONDBLCLK 0x209
Double-click the middle mouse button
#DeFine WM_MouseWheel 0x20a
Sends this message when the mouse wheel is rotated a control that currently has focus
===================
Button
===================
Bm_click button is clicked on message
The Bm_getcheck is used for check boxes or radio boxes. See if it's checked.
Bm_getstate sends this message, which returns the state of the button, such as whether it is checked, whether it is available (grayed out if not available)
Bm_setcheck If it has been checked, after sending this message, it becomes unchecked, that is, the hook is not selected. Ok?
Bm_setstate Settings button is clicked.
====================
Combo
===================
Cb_addstring adds a string to Combo Boxes.
Cb_deletestring Delete entries in the Combo Boxes, both item
Cb_getcount gets the number of Combo Boxes entry item
Cb_getcursel returns the position of the selected entry in the Combo Boxes in the Combo Boxes, and the first is 0.
Returns 1 if there are no entries or errors
Cb_getdroppedstate send this message, you can determine whether the Combo Boxes list box is dropped, if yes, return a value other than 0, not, then return 0
Cb_getlbtext gets the text of the combo box entry. The return value is the length of this text.
The Cb_getlbtextlen return value is the length of the text of the entry.
Cb_insertstring inserting string entries into combo box
Cb_resetcontent Empty combo box all entries
Cb_setcursel Set combo box to be selected entries.
Cb_showdropdown let combo box's listbox drop down. Showing all the entries
===================
Edit
===================
Em_canundo determines whether the last action can undo (undo action). If you can, you can send Em_undo
Em_getfirstvisibleline in the multi-line control, find the topmost visible line number. The dandy number is relative to all rows.
Em_getpasswordchar returns the character set of the Password box. Both view passwords.
Em_getsel returns the position of the start and end point of the character set in the editable control, which is selected (Highlight high-volume selection).
Returns the start position with the wparam parameter of the SendMessage, LParam returns to the end position
Em_replacesel Replace a string in an editable control with a different string, and this message becomes a string if there is no string in the editable control
Em_setpasswordchar Setting the password character set in an editable control, using * instead of
Em_undo the Send action to undo the message.
======================
IP Address
===================
Ipm_clearaddress clearing the contents of an IP address control
Ipm_getaddress Gets the IP address information stored in it from the IP address control/
Ipm_isblank determines whether the IP address control can be a null value. An address such as 127.0.0.1 is empty.
Ipm_setaddress set the IP address in the IP address control.
Ipm_setfocus in the IP address control, when you need to enter an IP address, get the keyboard input focus
Ipm_setrange setting the valid range of the input IP address
=====================
Media Control Interface (MCI)
=============================
Mm_mcinotify tells the form the status of the MCI command to complete. This state includes success, failure, or other events
Menu
=============================
WM_COMMAND when the user selects an item in the menu, the message is sent to the form. The form receives this message and then decides on the next behavior
Wm_initmenu This message is sent to the form before the menu is ready to be displayed, and the form initializes the menu item.
Wm_syscommand sends the user to the form to click on the System menu message. The form responds to this message and determines the next behavior.
================
Window messages
=====================
Wm_close sends a message that causes the form to close, and some forms will pop up at this point to close the dialog box.
Wm_gettext returns the form title bar (Caption property). You need to get the string length with Wm_gettextlength first
Wm_gettextlength, see you!
Wm_help The specified Help file is displayed when this message is sent
Wm_settext set the form title bar.
==============================
ListBox
===============
Lb_addstring Adding a string to an entry
Lb_deletestring Delete an entry. The entry sequence number is starting from 0.
Lb_getcount gets the total number of entries.
Lb_getcursel get the serial number of the option entry for the Radio list box
Lb_getsel determines if the list entry is selected, and if it is selected, returns the value of >0. Otherwise, 0 is returned, indicating that the user has not selected an entry
Lb_getselcount Gets the list of multiple choices, the number of entries selected by the user.
Lb_getselitems returns the ordinal number of the selected item of the list that can be selected. can return an array.
Lb_gettext gets the text value of an entry in the list
Lb_gettextlen gets the length of the text value of an entry in the list
Lb_insertstring in the list, insert an entry. If successful, returns the ordinal of the entry after it is inserted.
Lb_resetcontent clears all the entries in the list.
Lb_setcursel to the Single list box, set the specific value of the user selection item
Lb_setsel to the Multiple-selection list box, set the specific value of the user-selected entry
=======================================================
Mouse
==================
WM_LBUTTONDBLCLK when the mouse is within a form range, tell this form that the left mouse button is double-clicked. return value 0
Wm_lbuttondown when the mouse is within a form range, tell this form that the left mouse button is clicked, and return a value of 0
Wm_lbuttonup when the mouse is within a form range, tell this form that the left mouse button is released, and return a value of 0
WM_MBUTTONDBLCLK when the mouse is within a form range, tell this form that the middle mouse button is double-clicked. return value 0
Wm_mbuttondown when the mouse is within a form range, tell this form that the middle mouse button is clicked, and the return value is 0
Wm_mbuttonup when the mouse is within a form range, tell this form that the middle mouse button is released, and the return value is 0
The difference between SendMessage and PostMessage