Solved

Manipulating the text in an edit control

Posted on 1998-11-11
2
184 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 53
NotAlone Challenge 20 88
MaxSpan challenge 9 124
Adjust the codes 3 33
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ā€¦
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.

733 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