?
Solved

How to position the caret in CEdit

Posted on 1998-11-05
7
Medium Priority
?
1,492 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
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!

 
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

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 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