Name

MSG

Synopsis

Contains all information that defines a Windows message:

Public Type MSG
    hwnd As Long
    message As Long
    wParam As Long
    lParam As Long
    time As Long
    pt As POINTAPI
End Type

Structure Members

hwnd

The handle of the window to which the message is directed.

message

The message to be passed to this window. All window messages are constants and are defined in the Win32 Software Development Kit (SDK) header files. The header files WINUSER.H and WINABLE.H contain most of these constants.

wParam and lParam

Many messages use the wParam and lParam elements to pass extra information to the receiving window procedure. This extra information depends on the message. For example, it could indicate which mouse button was pressed, or if the Ctrl key was pressed in combination with the currently pressed key. Some messages need to pass much more information than is possible with the wParam and lParam arguments. To get around this limitation, some messages have special structures associated with them. Pointers to these structures are passed in either the lParam or the wParam elements.

Each message has its own identity -- that is, the way one message fills in the MSG structure is not the way every message will fill it in. Most messages have their own information that must be passed on to the receiving window. Therefore, become familiar with the message that you are going to be trapping before you write the code or you might be in for a surprise.

time

Represents when the message was posted. ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.