EM_CHARFROMPOS

The EM_CHARFROMPOS message retrieves the character index and line index of the character nearest a specified point in the client area of an edit control. The application can send this message to either an edit control or a rich edit control.

Rich edit controls use the following syntax:

EM_CHARFROMPOS
wParam = 0;                        // not used
lParam = (LPARAM) (POINTL *) lpPoint;
     // pointer to a POINTL structure with the point coordinates
 

Edit controls use the following syntax:

EM_CHARFROMPOS
wParam = 0;                        // not used
lParam = MAKELPARAM(xPos, yPos);   // coordinates of a point
 

Parameters

lParam
Specifies the coordinates of a point in the control's client area. The coordinates are in screen units and are relative to the upper-left corner of the control's client area.

Rich edit controls: lParam is a pointer to a POINTL structure that contains the horizontal and vertical coordinates.

Edit controls: The low word of lParam contains the horizontal coordinate. The high word contains the vertical coordinate.

Return Values

The low word of the return value specifies the zero-based index of the character nearest the specified point. This index is relative to the beginning of the control, not the beginning of the line. If the specified point is beyond the last character in the edit control, the return value indicates the last character in the control.

The high word of the return value specifies the zero-based index of the line that contains the character. For single-line edit controls, this value is zero. The index indicates the line delimiter if the specified point is beyond the last visible character in a line.

QuickInfo

  Windows NT: Requires version 4.0 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.

See Also

Edit Controls Overview, Edit Control Messages, EM_POSFROMCHAR, POINTL