Solved

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

Posted on 2000-03-10
4
687 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 80 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

Technology Partners: 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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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