?
Solved

caret index in CRichEditCtrl

Posted on 2002-04-01
7
Medium Priority
?
499 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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