Solved

Setting Focus

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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