Solved

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

Posted on 2000-03-10
4
673 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 78
modThree challenge 4 64
FizzBuzz challenge 9 73
Not needed 13 54
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now