Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to position the caret in CEdit

Posted on 1998-11-05
7
Medium Priority
?
1,498 Views
Last Modified: 2013-11-20
When I select the entire text in an edit box by calling CEdit::SetSel, the caret is automatically moved to the end of the selection.  However, I want to be able to keep the caret at the beginning of the text when it's highlighted, not at the end of it.  So the question is, is there a way to move the caret to position 0 in a CEdit when the text highlighted?
Toan Phan
0
Comment
Question by:toanphan
[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
7 Comments
 

Expert Comment

by:ddeboskey
ID: 1324259
A call to SetCaretPos should be able to move the caret after the call to SetSel.  Since SetCaretPos takes an X and Y coordinate, you may need to call CEdit::PosFromChar() in order to obtain the correct coordinates for the right character index.  

I hope this helps.
Dave.
0
 

Author Comment

by:toanphan
ID: 1324260
The caret is a shared resource, and a call to SetCaretPos for CEdit does not have any effect.  Any examples how to do this would really help.
Thanks.
0
 

Author Comment

by:toanphan
ID: 1324261
The caret is a shared resource, and a call to SetCaretPos for CEdit does not have any effect.  Any examples how to do this would really help.
Thanks.
0
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.

 
LVL 1

Expert Comment

by:Bridge
ID: 1324262
Use CEdit::SetSel(...)
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1324263
Sorry, didnt read the question fully. The answer is not there isnt.
0
 

Author Comment

by:toanphan
ID: 1324264
Bridge did not give the answer as he misread the question.  Any other answers?
0
 
LVL 2

Accepted Solution

by:
wyy_cq earned 200 total points
ID: 1324265
CWnd::SetCaretPos(CPoint pt) may work .
you can calculate the width of the string and place the caret to the correct position.
0

Featured Post

Independent Software Vendors: 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

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…
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…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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