?
Solved

Trapping Edit Box Focus Events in VC++

Posted on 2003-03-10
6
Medium Priority
?
649 Views
Last Modified: 2012-06-27
I currently trap the EN_SETFOCUS and EN_KILLFOCUS events to perform pre and post edit box processing.  This works correctly until the users swaps to another application while an edit box has the focus.  The edit box physically loses focus but not logically.  How do I trap the ENTER and EXIT events in VC++ that are present in VB and Delphi?
0
Comment
Question by:wtfinc
[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
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 8102982
When a user switches to a different application, the previous app in use should receive a WM_KILLFOCUS. That should work...
0
 

Author Comment

by:wtfinc
ID: 8103032
When the user switches to a different application, I want the focus to stay in the edit box because the user has not finished entering data.  I need to trap an event other than the WM_KILLFOCUS.  My question is which event and how do I trap it?
0
 
LVL 86

Expert Comment

by:jkr
ID: 8103174
>> I want the focus to stay in the edit box

With another app being activated?
0
Industry Leaders: 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!

 

Author Comment

by:wtfinc
ID: 8103256
Yes.  When the user comes back to my app, I want the focus to still be in the same edit box they were in when they left.  I believe this is the way the OnEnter and OnExit events work in VB and Delphi.  Switching to another application when an edit box has the focus will fire the KillFocus event but not the Exit event.  Hitting the TAB, ENTER or clicking on another control would fire the Exit event.
0
 
LVL 3

Accepted Solution

by:
cmaryus earned 1500 total points
ID: 8103630
You can use Spy++ from "Microsoft Visual Studio 6.0 Tools" menu. with it you can see all the messages that a window receives.
0
 

Author Comment

by:wtfinc
ID: 8104367
Good Suggestion.  There doesn't appear to be any events generated other than the KILLFOCUS.  I'll have to examine which new control has the focus in my KILLFOCUS event handler.  If null, I'll assume the user has swapped applications.  Thanks for the help
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 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