CEdit::CharFromPos

Call this function to retrieve the zero-based line and character indices of the character nearest the specified point in this CEdit control

int CharFromPos( 
   CPoint pt  
) const;

Parameters

  • pt
    The coordinates of a point in the client area of this CEdit object.

Return Value

The character index in the low-order WORD, and the line index in the high-order WORD.

Remarks

Note

This member function is available beginning with Windows 95 and Windows NT 4.0.

For more information, see EM_CHARFROMPOS in the Windows SDK.

Example

// CMyEdit inherits from CEdit 
void CMyEdit::OnLButtonDown(UINT nFlags, CPoint point)
{
   int n = CharFromPos(point);
   int nLineIndex = HIWORD(n);
   int nCharIndex = LOWORD(n);
   TRACE(_T("nLineIndex = %d, nCharIndex = %d\r\n"), nLineIndex, nCharIndex);

   CEdit::OnLButtonDown(nFlags, point);
}

Requirements

Header: afxwin.h

See Also

Reference

CEdit Class

Hierarchy Chart

CEdit::PosFromChar

Other Resources

CEdit Members