Solved

From Mouse Position To Text Beneath - CRichEditCtrl

Posted on 2001-07-30
6
292 Views
Last Modified: 2013-11-20
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
Comment
Question by:RichJackson
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6333605
Hi!
there is message for this:
EM_CHARFROMPOS
0
 

Author Comment

by:RichJackson
ID: 6334775
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
 
LVL 12

Expert Comment

by:migel
ID: 6334788
Hi!
IMHO you must convert pt to the RichEdit client coords.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:RichJackson
ID: 6335046
I guess that would explain it, whats the best way of doing the conversion.
0
 
LVL 12

Accepted Solution

by:
migel earned 15 total points
ID: 6335280
hm

POINT pt;
GetCursorPos(&pt);
m_note.ScreenToClient(&pt);
0
 

Author Comment

by:RichJackson
ID: 6336990
Cheers, much appreciated
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now