WM_MBUTTONDBLCLK Message

Platforms

Description & Usage

The WM_MBUTTONDBLCLK message tells a window that the middle mouse button has been double-clicked while the cursor is inside the window's client area. The information sent with the message identifies the cursor postion relative to the window as well as the state of various modifier keys and mouse buttons. The target window's window procedure processes the message. When handling the message, the GET_X_LPARAM, GET_Y_LPARAM, and MAKEPOINTS macros can be used to unpack the coordinate information easily.

Return Value

WM_MBUTTONDBLCLK should always return 0.

Visual Basic-Specific Issues

None.

Parameters

wParam
A combination of the following flags specifying which modifer keys, if any, are currently depressed:
MK_CONTROL
The Ctrl key is down.
MK_LBUTTON
The left mouse button is down.
MK_MBUTTON
The middle mouse button is down.
MK_RBUTTON
The right mouse button is down.
MK_SHIFT
The Shift key is down.
MK_XBUTTON1
Windows 2000: The first X button is down.
MK_XBUTTON2
Windows 2000: The second X button is down.
lParam
The (x,y) coordinates of the mouse cursor relative to the window. The low-order word contains the x-coordinate, and the high-order word contains the y-coordinate.

Constant Definitions

Const WM_MBUTTONDBLCLK = &H209
Const MK_CONTROL = &H8
Const MK_LBUTTON = &H1
Const MK_MBUTTON = &H10
Const MK_RBUTTON = &H2
Const MK_SHIFT = &H4
Const MK_XBUTTON1 = &H20
Const MK_XBUTTON2 = &H40

Example

' This code is licensed according to the terms and conditions listed here.

' Make window Form1 think that the middle mouse button has been
' double-clicked in its center by sending the appropriate message to it.
Dim xcoord As Long, ycoord As Long  ' x and y coordinates of the faked cursor position
Dim packed As Long  ' the coordinates "packed" into a single 32-bit integer
Dim winrect As RECT  ' receives coordinates of the window
Dim retval As Long  ' return value

' First, get the coordinates of window Form1.
retval = GetWindowRect(Form1.hWnd, winrect)
' Use the coordinates to calculate the midpoint of Form1.
xcoord = (winrect.right - winrect.left) / 2
ycoord = (winrect.bottom - winrect.top) / 2
' Now pack the coordinates into the appropriate words of the value
packed = (ycoord * &H10000) + xcoord

' Make Form1 think the middle mouse button was just double-clicked in that position.
retval = SendMessage(Form1.hWnd, WM_MBUTTONDOWN, ByVal CLng(MK_MBUTTON) , ByVal packed)
retval = SendMessage(Form1.hWnd, WM_MBUTTONUP, ByVal CLng(0), ByVal packed)
retval = SendMessage(Form1.hWnd, WM_MBUTTONDBLCLK, ByVal CLng(MK_MBUTTON), ByVal packed)
retval = SendMessage(Form1.hWnd, WM_MBUTTONUP, ByVal CLng(0), ByVal packed)

See Also

WM_LBUTTONDBLCLK, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_RBUTTONDBLCLK

Category

Mouse

Back to the Message list.
Back to the Reference section.


Last Modified: March 19, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/w/wm_mbuttondblclk.html