Solved

Setting Focus

Posted on 1999-01-06
4
223 Views
Last Modified: 2013-11-20
I have an Edit control and a check box and the tab order is set in that order , i make a validation for the text entered in the edit box control and if the validation fails , i set the focus back to the edit control but the focus is not going to the edit control but to the check box since that is next to edit control in tab order , why is that ? and How can i set the focus back to the edit control ?
0
Comment
Question by:NaveenKumar
  • 2
  • 2
4 Comments
 

Author Comment

by:NaveenKumar
ID: 1327341
Edited text of question
0
 
LVL 4

Accepted Solution

by:
pagladasu earned 20 total points
ID: 1327342
Here is what you should do. Use classwizard to map the EN_KILLFOCUS of the edit control. Assuming that its ID value is IDC_EDIT1, use code something like this:

void CMyDlg::OnKillfocusEdit1()
{
      // TODO: Add your control notification handler code here
      UpdateData(TRUE);
      if(m_edit!="Hello") //m_edit is a CString variable associated with the control
            GetDlgItem(IDC_EDIT1)->SetFocus();
}

hope this helps
thanks
pagladasu
0
 

Author Comment

by:NaveenKumar
ID: 1327343
Thanx for ur answer , actually i am not making use of any wizards in my project , but manually writing the cpp and header codes and inserting it into the project , I have trapped the kill focus as you have said and the validation is done there itself and i have also set back the focus in Kill focus as you have mentioned but even after doing all this the focus is set on the check box and not on the edit control .
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1327344
Could you please post the code.
Email to:espical@hotmail.com
As far as the above code is concerned, I have tried it out, and it works.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

18 Experts available now in Live!

Get 1:1 Help Now