This function, added in VFP 6, gives you information about the current position of the mouse pointer.
nFoundSomething = AMouseObj( Info [, nRelativeToForm ] )
Parameter |
Value |
Meaning |
Info |
Array Name |
The array to hold the results of the function. |
nRelativeToForm | Omitted |
Return information about the mouse position relative to the container of the object over which the mouse is positioned. |
1 (or any other value) |
Return information about the mouse position relative to the containing form. |
|
nFoundSomething |
4 |
The mouse is positioned over an object and the array has been filled with the information. |
0 |
The mouse is positioned over something that's not an object in the sense of this function and the array is unchanged. |
AMouseObj()
recognizes any VFP form or control, along with some parts of the development environment. If the mouse is outside VFP or over one of the unrecognized objects, the function returns 0 and leaves the array alone. For no reason we can think of, Browses are among the unrecognized objects even though they're really grids internally.
The function fills the first two array elements with object references to the object itself and the object's container. The third and fourth elements contain the coordinates (in pixels) of the mouse position relative to the container. However, if the optional second parameter is passed, the second element gets a reference to the containing form, no matter how deep in the hierarchy the control is. In that case, the point returned in the third and fourth elements is instead relative to the form.
You need to release the array (or at least null the first two elements) before you can release the form. Otherwise, the references in the array prevent the form from being destroyed. |
Like SYS(1270), this function tells you about the mouse position without requiring a click. Because it's available at design-time as well as runtime (as is SYS(1270)), we suspect it'll see a lot of use in builders.
* Find out if we're over a particular object
IF AMouseObj(aWhereAreWe) = 4
* Got something
IF aWhereAreWe[1] = oSomeObject && note that we can now
&& compare objects directly
* Do something
ELSE
* Do something different
ENDIF
ENDIF