Complete use manual for SendMessage Functions

Source: Internet
Author: User

Http://www.chenjiliang.com/Article/View.aspx? ArticleID = 4519


SendMessage function full user manual
First, let's take a look at the message mechanism of Windows. Windows is a message-driven system. Windows message provides a means of communication between an application and an application, and between an application and a Windows system.
For example, open the Notepad program, which has a "file" menu. When running the program, if you click the "new" command in the "file menu,
This action will be captured by Windows. After analysis, Windows will find that this action should be handled by the Notepad program we opened, and then Windows will send a message.
For example, when programming, we sometimes use the WM_COMMAND message to the notepad, and then the notepad will process the message. This process is message processing.
Next, let's talk about SendMessage in the complete form.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal
Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
As Long
Alias
SendMessageA
Description
Call the window function of a window and send a message to that window. This function will not return unless the message is processed.

SendMessage contains four parameters.
Hwnd 32-bit window handle window can be any type of screen object, because Win32 can maintain the handle of most visual objects
WMsg is used to distinguish the constant values of other messages. These constants can be pre-defined constants in Windows units, or custom constants. wParam is usually a message-related constant value, it may also be the handle of a window or control.
LParam is usually a pointer to data in the memory. Since WParm, lParam, and Pointer are both 32-bit, they can be converted to each other.
WMsg Function
WM_CREATE create a window
WM_DESTROY is sent when a window is damaged
WM_MOVE move a window
WM_SIZE changes the size of a window.
WM_ACTIVATE a window is activated or inactive
WM_SETFOCUS: one window obtains the focus
WM_KILLFOCUS: A window loses focus.
WM_ENABLE a window changes to Enable status
WM_SETREDRAW: Specifies whether the window can be repainted.
The WM_SETTEXT application sends this message to set the text of a window.
The WM_GETTEXT application sends this message to copy the text of the corresponding window to the buffer zone.
WM_GETTEXTLENGTH: Get the length of the text related to a window (excluding empty characters)
WM_PAINT requires a window to redraw itself
WM_CLOSE send a signal when a window or application is closed
WM_QUERYENDSESSION: when the user selects the end dialog box or the program calls the ExitWindows Function
WM_QUIT is used to end the program running
WM_QUERYOPEN send this message to an icon when the user window recovers the previous size position
WM_ERASEBKGND: when the window background must be erased (for example, when the window size changes)
WM_SYSCOLORCHANGE send this message to all top-level windows when the system color changes
WM_ENDSESSION when the system process sends the WM_QUERYENDSESSION message, the message is sent to the application to notify it of the end of the conversation.
WM_SHOWWINDOW: When a hidden or displayed window is used, this message is sent to this window.
WM_ACTIVATEAPP sends this message to the application, which window is activated and which is not activated.
WM_FONTCHANGE send this message to all top-level windows when the system's Font Resource Library changes
WM_TIMECHANGE send this message to all top-level windows when the system time changes
WM_CANCELMODE sends this message to cancel an ongoing touch (Operation)
WM_SETCURSOR if the mouse causes the cursor to move in a window and the mouse input is not captured, a message is sent to a window.
WM_MOUSEACTIVATE when the cursor is in an inactive window and the user is pressing a key of the mouse to send this message to the current window
WM_CHILDACTIVATE sends this message to the MDI subwindow. When the user clicks the title bar of this window, or when the window is activated, move and change the size
WM_QUEUESYNC this message is sent by a computer-based training program, and the user input message is separated by the WH_JOURNALPALYBACK hook program.
WM_GETMINMAXINFO this message is sent to the window when it is about to change the size or position
WM_PAINTICON is sent to the minimization window when its icon is to be repainted
WM_ICONERASEBKGND this message is sent to a minimal window, and its background must be repainted only when it is before the icon is painted.
WM_NEXTDLGCTL sends this message to a dialog box program to change the focus position
WM_SPOOLERSTATUS this message is sent whenever a job is added or removed in the print management queue.
WM_DRAWITEM is sent when the visual appearance of button, combobox, listbox, and menu changes
WM_MEASUREITEM when button, combo box, list box, list view control, or menu item is created
WM_VKEYTOITEM this message has an LBS_WANTKEYBOARDINPUT style sent to its owner to respond to the WM_KEYDOWN message
WM_CHARTOITEM the message is sent to the owner by a list box in the LBS_WANTKEYBOARDINPUT style to respond to the WM_CHAR message.
WM_SETFONT when drawing text, the program sends this message to obtain the color used by the Control
The WM_GETFONT application sends this message to obtain the font of the text drawn by the current control.
The WM_SETHOTKEY application sends this message to connect a window to a hotkey.
The WM_GETHOTKEY application sends this message to determine whether the hotkey is associated with a window.
WM_QUERYDRAGICON the message is sent to the minimization window. When the window is to be dragged and its class does not have a defined icon, the application can return an icon or a cursor handle.
This icon or cursor is displayed when you drag and drop an icon.
WM_COMPAREITEM sends this message to determine
Determine the relative position of the newly added items in combobox or listbox
WM_COMPACTING shows that the memory is very small
When WM_WINDOWPOSCHANGING sends this message to the window whose size and position will be changed, it calls the setwindowpos function or other window management functions.
When WM_WINDOWPOSCHANGED sends this message to the window whose size and position have been changed, it calls the setwindowpos function or other window management functions.
WM_POWER sends this message when the system is about to pause
Message
WM_COPYDATA: This message is sent when an application transmits data to another application.
WM_CANCELJOURNA when a user cancels the activation status of the program log, submit the message to the program
WM_NOTIFY when an event of a control has occurred or
When this control needs to obtain some information, it sends this message to its parent window.
WM_INPUTLANGCHANGEREQUEST
WM_INPUTLANGCHANGE send this message to the affected top-level window when the platform site has been changed
WM_TCARD when the program has initialized the windows Help example
Send this message to the application
WM_HELP: the message indicates that the user presses F1.
When a menu is activated, the message is sent to the associated menu of the window. Otherwise, the message is sent to the window with focus. If no focus exists, send the message to the currently activated window.
WM_USERCHANGED: when the user has logged on or exited, this message is sent to all windows. When the user logs on or exits, the system updates the user's specific settings. When the user updates the settings, the system immediately sends this message.
Wm_policyformat public control. The custom control and its parent window use this message to determine whether the control uses the ANSI or UNICODE structure.
WM_CONTEXTMENU: Right-click a user in a window and send the message to this window.
WM_styleCHANGING send this message to the window when the SETWINDOWLONG function is called to change the style of one or more windows
WM_styleCHANGED: When the SETWINDOWLONG function is called for one or more windows, this message is sent to that window.
WM_DISPLAYCHANGE send this message to all windows after the display resolution changes
WM_GETICON the message is sent to a window to return
Window-related large icon or small icon handle
WM_SETICON program sends this message to make a new big icon
Or associate a small icon with a window.
WM_NCCREATE when a window is created for the first time, this message is sent before the WM_CREATE message is sent.
WM_NCDESTROY this message notifies a window, not the customer area
Destroying
WM_NCCALCSIZE when the customer area of a window must be checked
Send this message during Calculation
WM_NCHITTEST move the mouse and press or release the mouse
Raw
The WM_NCPAINT program sends this message to a window when it
(Window) frame must be drawn
WM_NCACTIVATE this message is sent to a window only when its
Non-customer zones need to be changed to show whether they are activated or not.
WM_GETDLGCODE sends this message to a dialog box Program
The left-side Navigation Pane and the left-side navigation pane of the left-side Navigation Pane.
WM_NCMOUSEMOVE send this message when the cursor moves in a non-customer area of a window to the non-customer area of the window: The title bar of the form and the border body of the window
WM_NCLBUTTONDOWN: this message is submitted when the cursor is in the non-customer area of a window and the left mouse button is pressed at the same time.
WM_NCLBUTTONUP
WM_NCLBUTTONDBLCLK: When you double-click the left mouse button and a window with the cursor sends this message in non-customer Zone 10
WM_NCRBUTTONDOWN: This message is sent when you right-click the user and the cursor is in a non-customer area of the window.
WM_NCRBUTTONUP: This message is sent when the user releases the right mouse and the cursor is in a non-customer area of the window.
WM_NCRBUTTONDBLCLK when the user double-click the right mouse and the cursor in a window in non-customer Zone 10 to send this message
WM_NCMBUTTONDOWN: This message is sent when you press the middle mouse button and the cursor is in a non-customer area of the window.
WM_NCMBUTTONUP: This message is sent when the user releases the middle mouse button and the cursor is in a non-customer area of the window.
WM_NCMBUTTONDBLCLK: This message is sent when you double-click the key and move the cursor to a non-customer area in the window.
WM_KEYFIRST WM_KEYDOWN press the next key
WM_KEYUP releases a key
WM_CHAR: press a key and the WM_KEYDOWN and WM_KEYUP messages have been sent.
Use the translatemessage function to translate WM_DEADCHAR
When a WM_KEYUP message is sent, the message is sent to a window with focus
WM_SYSKEYDOWN when the user presses the ALT key and other
When the key is used, submit the message to the window with focus
WM_SYSKEYUP
The message is also submitted to the window with focus when it is pressed.
WM_SYSCHAR when WM_SYSKEYDOWN message
After being translated by the TRANSLATEMESSAGE function, submit this message to the window with focus
WM_SYSDEADCHAR when WM_SYSKEYDOWN message
This message is sent to the window with focus after being translated by the TRANSLATEMESSAGE function.
WM_INITDIALOG is sent before a dialog box program is displayed.
Send this message to it. This message is usually used to initialize the control and execute other tasks.
WM_COMMAND when you select a menu command item or when a control sends a message to its parent window, a shortcut key is translated
WM_SYSCOMMAND
To or when the user chooses to maximize or minimize the number of messages received in that window
A timer event occurs in WM_TIMER.
WM_HSCROLL: when a standard horizontal scroll bar of a window generates a rolling event, this message is sent to that window and the control that owns it.
WM_VSCROLL: when a standard vertical scroll bar of a window generates a rolling event, this message is sent to that window and the control that owns it.
WM_INITMENU sends this message when a menu is to be activated. It occurs in a menu bar of the user or presses a menu key, which allows the program to change the menu before display.
WM_INITMENUPOPUP send this message when a drop-down menu or sub-menu is to be activated. It allows the program to change the menu before it is displayed, instead of changing all
WM_MENUSELECT is sent when a menu item is selected
This message is sent to the menu owner (usually a window)
WM_MENUCHAR when the menu has been activated and the user presses a key (different from the acceleration Key), this message is sent to the menu owner
WM_ENTERIDLE sends this message to its owner when a modal dialog box or menu enters the no-load status, when a modal dialog box or menu enters the no-load status, it waits for no messages in the queue after processing one or more previous messages.

WM_CTLCOLORMSGBOX sends the message to the owner window of the message box before drawing the message box in windows, in the owner window, you can set the text and background color of the message box by using the given handle of the display device.
WM_CTLCOLOREDIT: When an editing control is to be drawn
When this message is sent to its parent window, the owner window can set the text and background color of the edit box by using the handle of the given display device.
WM_CTLCOLORLISTBOX when a list box control is to be drawn, send this message to its parent window in response to this message, in the owner window, you can set the text and background colors of the list box by using the given handle of the display device.
WM_CTLCOLORBTN when a button control is to be drawn
The parent window that sends this message responds to this message. The owner window can set the text and background color of the button by using the handle of the specified display device.
WM_CTLCOLORDLG when a dialog box control is to be drawn
Send this message to its parent window. In response to this message, the owner window can set the text background color of the dialog box by using the handle of the given display device.
WM_CTLCOLORSCROLLBAR send this message when a scroll bar control is to be drawn to its parent window to respond to this message. The owner window can set the background color of the scroll bar by using the handle of the given display device.
WM_CTLCOLORSTATIC: When a static control is to be drawn, this message is sent to its parent window to respond to this message, in the owner window, you can set the text and background color of the static control by using the given handle of the display device.
WM_MOUSEFIRST WM_MOUSEMOVE move the mouse
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK double-click the left mouse button
WM_RBUTTONDOWN right-click
WM_RBUTTONUP right-click to release
WM_RBUTTONDBLCLK, right-click
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCLK double-click
WM_MOUSEWHEEL: A control with focus is sent when the mouse wheel is turned.
WM_PARENTNOTIFY when the MDI child window is created or destroyed
Or the user presses the mouse key and the cursor sends the message to its parent window when the child window is located.
WM_ENTERMENULOOP sends this message to notify the application
Main Window that has entered the menu loop mode
WM_EXITMENULOOP sends this message to the application
Main Window that has exited the menu loop mode
WM_SIZING: when the user is adjusting the window size, the user can send this message to the window. Through this message application, the user can monitor the window size and position and modify them.
WM_CAPTURECHANGED send this message to the window when it is missing
When capturing the mouse
WM_MOVING: This message is sent when the user moves the window. With this message application, the user can monitor the window size and position and modify them.
WM_POWERBROADCAST this message is sent to the application

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.