Click here to Skip to main content
12,830,433 members (44,535 online)
Click here to Skip to main content
Add your own
alternative version


16 bookmarked
Posted 9 Aug 2002

Quick positioning of the caret at the end of the text

, 9 Aug 2002
Rate this:
Please Sign up or sign in to vote.
Quickly position the caret at the end of edit control text...


I was using EditControl window to dump some logging/trace messages line by line and found out that a simple routine involving:


works only if you don't reposition the caret in EditControl window (which inadvertantly happens when you scroll back and forth to check on previous messages...). So, if you by accident repositioned the caret, the next text dump will disrupt existing line and produce undesirable effect of garbled data...

A Solution

A simple workaraound may help -- the following "duo" does the trick:

SendDlgItemMessage(hwndDlg,IDC_SOMEEDITCONTROL, EM_SETSEL, 0, -1);
SendDlgItemMessage(hwndDlg,IDC_SOMEEDITCONTROL, EM_SETSEL, -1, -1);

This will position a runaway caret to the end of the text in EditControl..., so that the next call to:


will append a new line to the bottom of the existing body of text... ;-)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
Programming "Artist" since 1984

You may also be interested in...

Comments and Discussions

GeneralCaret at the beginning Pin
Filomela28-Apr-04 4:37
memberFilomela28-Apr-04 4:37 
GeneralRe: Caret at the beginning Pin
toxcct5-Aug-05 0:46
membertoxcct5-Aug-05 0:46 
QuestionHow to highlight a particular line in edit box? Pin
Rajksingh17-Sep-03 4:46
memberRajksingh17-Sep-03 4:46 
AnswerMFC Solution Pin
John A. Johnson31-Oct-03 12:01
memberJohn A. Johnson31-Oct-03 12:01 
AnswerSDK Solution Pin
John A. Johnson31-Oct-03 12:10
memberJohn A. Johnson31-Oct-03 12:10 
AnswerAuto scroll Pin
a.bietti8-Dec-04 6:34
membera.bietti8-Dec-04 6:34 
GeneralRe: Auto scroll Pin
428819-Jul-07 6:33
member428819-Jul-07 6:33 
GeneralAll Documented in MSDN Pin
Norm Almond10-Aug-02 9:16
memberNorm Almond10-Aug-02 9:16 
GeneralRe: All Documented in MSDN Pin
bob169728-Sep-03 7:20
memberbob169728-Sep-03 7:20 
GeneralRe: All Documented in MSDN Pin
Normski10-Sep-03 8:52
memberNormski10-Sep-03 8:52 
GeneralRe: All Documented in MSDN Pin
bob1697223-Jan-04 17:05
memberbob1697223-Jan-04 17:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170326.1 | Last Updated 10 Aug 2002
Article Copyright 2002 by Botticelli
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid