Solved

Manipulating the text in an edit control

Posted on 1998-11-11
2
173 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
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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