Solved

CRichEditCtrl: get current caret pos. as offset to line-begin

Posted on 1998-03-11
4
702 Views
Last Modified: 2013-11-20
I need to determine the position of the caret (after character input) relative to the begin of the current line.
In a CRichEditCtrl i can get the current line via "LineFromChar(-1)". There is no class member function to determine the current caret pos relative to the line-beginning. Do i have to trap On_Char() and count the chars input for each line to get current caret pos or is there a
better solution ?
0
Comment
Question by:focht
  • 3
4 Comments
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316907
CRichEditCtrl::LineIndex( iLine ) gives you the char position of the start of the specified line.

-=- James.

0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316908
No, i don't want an offset relative to the beginning of the control (1.st line, 1.st char) (that is all that LineIndex(i) does). I need the character offset relative to the beginning of the current line (line x: character 1 = offset 0 ...).
Ex: caret at pos 10 in line 5 = offset 10.
 
0
 
LVL 1

Author Comment

by:focht
ID: 1316909
  You use the value returned from LineIndex( iLine ) with the current caret position.  That gives you the char position of the current line.

   GetSel( iSelStart, iSelEnd )
   iColumn = ( iSelEnd - LineIndex( -1 ) );

   See?

-=- James.

0
 
LVL 4

Accepted Solution

by:
jtwine100697 earned 50 total points
ID: 1316910
  Note that if you are trying to create some kind of editor, this will not "expand" tabs correctly...

-=- James.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

14 Experts available now in Live!

Get 1:1 Help Now