Solved

Manipulating the text in an edit control

Posted on 1998-11-11
2
192 Views
Last Modified: 2013-11-20
Using MFC
I have an edit control that I read as the user enters the data.
If the length equal 4 then i take it and and a " - " like so:

void CCompany::OnChangeedtActivePeriod()
{
// TODO: Add your control notification handler code here
int nSize;

UpdateData( TRUE );
nSize = strlen( m_edtActivePeriod );
if( nSize == 4 ){
  CString strBuff;
  strBuff = m_edtActivePeriod + " - ";
  m_edtActivePeriod = strBuff;
  UpdateData( FALSE );
}

}

But when I send it I want the cursor/line to be after the space like so:
User enters: 1998
I take it and add
1998 -
and put it back on the edit control
but want to put the cursor after the space like so:
1998 - |
so the user can enter other data
How do I do that?
Thanks

0
Comment
Question by:eric07
[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 Comments
 
LVL 2

Accepted Solution

by:
wyy_cq earned 50 total points
ID: 1324546
do not use UpdateData(FALSE)
but use

ed=GetDlgItem(IDC_EDIT_ID);// the CWnd point
ed->SetFocus();
ed->SetWindowText(strBuff);
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1324547
Won't the entire text be highlighted?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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