• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

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
0
RichJackson
Asked:
RichJackson
  • 3
  • 3
1 Solution
 
migelCommented:
Hi!
there is message for this:
EM_CHARFROMPOS
0
 
RichJacksonAuthor Commented:
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!

0
 
migelCommented:
Hi!
IMHO you must convert pt to the RichEdit client coords.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
RichJacksonAuthor Commented:
I guess that would explain it, whats the best way of doing the conversion.
0
 
migelCommented:
hm

POINT pt;
GetCursorPos(&pt);
m_note.ScreenToClient(&pt);
0
 
RichJacksonAuthor Commented:
Cheers, much appreciated
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now