The WM_LBUTTONDBLCLK message tells a window that the left 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.
WM_LBUTTONDBLCLK should always return 0.
It is not necessary to create a special hander for the WM_LBUTTONDBLCLK message. The DblClick event handler provided by Visual Basic actually process WM_LBUTTONDBLCLK and unpacks some of the information passed with it for easier use.
Const WM_LBUTTONDBLCLK = &H203
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
' This code is licensed according to the terms and conditions listed here.
' Make window Form1 think that the left 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 right mouse button was just double-clicked in that position.
retval = SendMessage(Form1.hWnd, WM_LBUTTONDOWN, ByVal CLng(MK_LBUTTON) , ByVal packed)
retval = SendMessage(Form1.hWnd, WM_LBUTTONUP, ByVal CLng(0), ByVal packed)
retval = SendMessage(Form1.hWnd, WM_LBUTTONDBLCLK, ByVal CLng(MK_LBUTTON), ByVal packed)
retval = SendMessage(Form1.hWnd, WM_LBUTTONUP, ByVal CLng(0), ByVal packed)
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDBLCLK, WM_RBUTTONDBLCLK
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_lbuttondblclk.html