Link to home
Start Free TrialLog in
Avatar of RichJackson
RichJackson

asked on

From Mouse Position To Text Beneath - CRichEditCtrl

I need to be able to grab the mouse move events while the user is moving over a CRichEditCtrl, and determine the character position of the mouse.  In other words, the OnMouseMove() method tells me a CPoint, where the mouse pointer is, and I need to convert this over to a
character position within the control.  

Anyone any ideas

Cheer

Rich
Avatar of migel
migel

Hi!
there is message for this:
EM_CHARFROMPOS
Avatar of RichJackson

ASKER

Cheers, but I gotta a problem with EM_CHARFROMPOS, it just give me zero.

Code below, thanks

CResultsDlg::PreTranslateMessage(MSG* pMsg)
{
  if (NULL != m_pToolTip)
      m_pToolTip->RelayEvent(pMsg);
     
  if (pMsg->message==WM_MOUSEMOVE && 
     pMsg->hwnd==m_note.m_hWnd )
  {
     long res;
         
     res = m_note.SendMessage(EM_CHARFROMPOS,0,(long)
                                  &pMsg->pt);

         
     //RES ALWAYS ZERO!

Hi!
IMHO you must convert pt to the RichEdit client coords.
I guess that would explain it, whats the best way of doing the conversion.
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers, much appreciated