getCtlCoord

Syntax

int getCtlCoord(int index, int type)

Arguments

index
The index of the control that you want to get the mouse coordinates for.
type
0 = Gets the x coordinate of the mouse pointer relative to this control (in pixels)
1 = Gets the y coordinate of the mouse pointer relative to this control (in pixels)

Return

Returns the x or y coordinate of the mouse cursor relative to the top left corner of the specified control, in pixels.
Returns -1 if the mouse pointer is outside the bounds of the control's window, or if there is any other error.

Description

Allows you to determine the coordinates (in pixels) of the current mouse cursor position over a control, for example when a button is clicked.
If index is equal to CTL_PREVIEW, the coordinates over the (primary) preview display are returned, adjusted relative to the top left corner of the proxy image (0,0). To get a coordinate relative to the full original image, multiply the proxy coordinate by scaleFactor (e.g., multiply by 4 at 25% zoom).
For other controls, the coordinates are relative to the top left corner of the control (e.g., for an OWNERDRAW control).

Also see

getPreviewCoordX, getPreviewCoordY, getCtlPos

Example

y = getCtlCoord(10, 1); // returns the y mouse coordinate relative to user control 10

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.