Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-03-10
4
Medium Priority
?
707 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:
Vinayak Kumbar 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

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

886 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