Solved

Setting Focus

Posted on 1999-01-06
4
224 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 48
Login Script to Copy Folders 12 29
viewing source code from eclipse 13 89
wordmultiple challenge 12 121
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 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

24 Experts available now in Live!

Get 1:1 Help Now