Solved

From Mouse Position To Text Beneath - CRichEditCtrl

Posted on 2001-07-30
6
297 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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