?
Solved

Resetting a control's focus upon windows regaining focus

Posted on 2005-03-31
2
Medium Priority
?
298 Views
Last Modified: 2010-04-16
Hi,

I just got a function which allows me to return the focus to a particular window, when I want to.  But the new problem is how do I record the control field which last had focus, so that I can return the focus to it?

I could come up with a hokey method where I retain an enumerated value, and each enumerated value relates to a particular control field.  But I'd like to see if there's a more elegant way, before I write it.

Does anybody have any idea about how to do this?

Thanks in advance.

Bob
0
Comment
Question by:ba272
[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 Comments
 
LVL 8

Accepted Solution

by:
AaronReams earned 2000 total points
ID: 13678292
Hi Bob,

This should all be handled for you automatically by windows.  This works for either inter-process or intra-process communication.  

You can test this by creating a simple form project and then creating two other forms.  Add a couple text boxes to each of the other forms and launch them modelessly (Show()).  You'll see as you switch back and forth (programatically by calling Form.Focus() or clicking with mouse) that the caret is in the textbox in each modeless form where you left it.

Something has probably gone awry in your app if focus is not maintained by the last control when you activate a form or process.  Are you perhaps forcing focus to another child control?

Hope this helps.

-Aaron
0
 

Author Comment

by:ba272
ID: 13678328
Thanks Aaron,

Actually, I was expecting it to be a problem and was circumventing the problem beforehand.  But come to think of it you're right.  Windows does that kind of work for me.
Problem solved.

That's a good thing to learn just before bed.

Good night.

Bob
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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 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