Solved

caret index in CRichEditCtrl

Posted on 2002-04-01
7
458 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 76
sum13 challenge 24 77
Use of condition with 'serial' in ansible 2 36
Sed question 2 48
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 discusses moving either the default database or any database to a new volume.

760 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

21 Experts available now in Live!

Get 1:1 Help Now