Windows API Guide: TrackPopupMenu Function


Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

The WM_MBUTTONUP message tells a window that the middle mouse button has been released 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_MBUTTONUP should always return 0.

Visual Basic-Specific Issues

It is not necessary to create a special hander for the WM_MBUTTONUP message. The MouseUp event handler provided by Visual Basic actually process WM_MBUTTONUP and unpacks some of the information passed with it for easier use.

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_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_MBUTTONUP = &H208 Const MK_CONTROL = &H8 Const MK_LBUTTON = &H1 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 ' released 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 released in that position. retval = SendMessage(Form1.hWnd, WM_MBUTTONUP, ByVal CLng(0), ByVal packed)

See Also

WM_LBUTTONUP, WM_MBUTTONDBLCLK, WM_MBUTTONDOWN, WM_RBUTTONUP

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_mbuttonup.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net