Export (0) Print
Expand All

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;

pt

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

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

NoteNote:

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

For more information, see EM_CHARFROMPOS in the Windows SDK.

// 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);
}

Header: afxwin.h

Community Additions

ADD
Show:
© 2015 Microsoft