Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Kill focus CEdit control

Posted on 2007-03-22
3
Medium Priority
?
2,030 Views
Last Modified: 2013-11-20
Hi,

I have a dialog containing 5 Edit boxes. Is there a way to handle the case where any one of those Edit boxes loses focus as opposed to putting an OnKillFocus event for every single Edit box?
Can this be done in MFC?

Regards,
maloriopolium
0
Comment
Question by:maloriopolium
[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
3 Comments
 
LVL 11

Expert Comment

by:Deepu Abraham
ID: 18777750
Add OnKillFocus handler for all the edit boxes.

Inside each one write

CWnd* pWndParent = GetParent();
pWndParent.SetFocus();

Also read:
www.codeproject.com/dialog/killfocus.asp

Best Regards,
DeepuAbrahamK
0
 
LVL 9

Accepted Solution

by:
Priyesh earned 200 total points
ID: 18784534
Manually add the following in your dialog cpp file in the message map section
      ON_CONTROL_RANGE(EN_KILLFOCUS, IDC_EDIT1, IDC_EDIT5, OnEditKillFocus)
Add handler in dialog as
void CDlgTestDlg::OnEditKillFocus(UINT unID)
{
      TRACE(_T("%d\n"), unID) ;
}
and in the header file,
afx_msg void OnEditKillFocus(UINT unID) ;

Note* the IDC_EDIT1 to IDC_EDIT5 must be in a continous range in ascending order for this to work. So if you have added controls to the dialog at different times, edit your resource.h to make sure these are continuous.
0
 

Author Comment

by:maloriopolium
ID: 18784708
Thanks Priyesh,

That worked exactly like I wanted it to.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

636 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