Solved

Manipulating the text in an edit control

Posted on 1998-11-11
2
153 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
Comment Utility
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
Comment Utility
Won't the entire text be highlighted?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Powershell based monitoring system 2 126
unable to delete all specified values regedit 38 148
Hibernate methods 2 58
pre4 challenge 19 87
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

9 Experts available now in Live!

Get 1:1 Help Now