[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 1998-03-11
4
Medium Priority
?
728 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 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