?
Solved

Visual C++ - UpdateData(), keeping cursor at end of string

Posted on 2000-03-10
4
Medium Priority
?
704 Views
Last Modified: 2013-11-20
I need to add a CString variable to an edit box and then immediately have the cursor at the end of the string in the edit box. I have been using UpdateData(FALSE) to display the variable in the edit box but this places the cursor at the start of the string.

Please help.
0
Comment
Question by:sjhl
[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
  • 2
4 Comments
 
LVL 1

Author Comment

by:sjhl
ID: 2606651
Adjusted points to 80
0
 
LVL 2

Expert Comment

by:dhymes
ID: 2606712
Looks like CEdit is derived from CWnd, CWnd has a method called SetCaretPos() so since your edit control is using a CEdit object to store the text you should be able to do something like

EditControlVariable.SetCaretPos(YourCStringVariable.GetLength());

See if that works for ya.
0
 
LVL 8

Accepted Solution

by:
VinExpert earned 320 total points
ID: 2607081
Hi,

Do like this after inserting the string

m_ctrlEdit.SetSel(m_strEdit.GetLength()-2, m_strEdit.GetLength()-1, FALSE);

Here m_ctrlEdit is the member variable for the edit control of CEdit type.
Here m_strEdit is the member variable for the edit control of CString type.

Hope that solves ur prob.

VinExpert
0
 
LVL 1

Author Comment

by:sjhl
ID: 2607535
Exactly what I wanted.

Thanks!
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

719 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