Solved

caret index in CRichEditCtrl

Posted on 2002-04-01
7
468 Views
Last Modified: 2013-11-20
How can I get the current character index, i.e., the index of the caret in CRichEditCtrl? There are functions to get current line index, no of lines but I do not find one to get caret index. Any help?
0
Comment
Question by:chhakuli
  • 4
  • 2
7 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6910904
Use GetSel:

long nStartPose, nEndPos;
m_ctlRichEd.void GetSel( nStartPos, nEndPos );

if ( nStartPos == nEndPos } {
        MessageBox("There no selection, only a caret");
} else {
        MessageBox("some text is selected");
}

-- Dan

0
 
LVL 4

Accepted Solution

by:
pagladasu earned 0 total points
ID: 6911246
Use
m_ctlRichEd.void GetSel( nStartPos, nEndPos );
if the values of nStartPos and nEndPos are both equal, then nStartPos or nEndPos will give you 'the index of the caret in CRichEditCtrl'.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6911278
Excellent observation pagladasu! I wish I'd said that!
-- Dan
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 49

Expert Comment

by:DanRollins
ID: 6911279
One typo.  Use:

m_ctlRichEd.GetSel( nStartPos, nEndPos );


0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6913920
chhakuli,

Why did you accept pagladasus'c comment as the answer?  It is very obviously a copy of my comment.  It even has the exact same typographical error!

-- Dan
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 6913945
U are right, DanRollins. I just made an observation on your comment based on the question. I think u should get the points.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6914337
This was the result of a database error, and points may not have properly gone to you .  Can you check for us?

We may need to do this question again if you can't see the points.

Moondancer - EE Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 77
bigDiff challenge 17 84
zeroMAx challenge 20 87
EvenOdd challenge 10 90
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

13 Experts available now in Live!

Get 1:1 Help Now