Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting Focus

Posted on 1999-01-06
4
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

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

Accepted Solution

by:
pagladasu earned 40 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

688 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