app loses focus after closing child form

H

Houston Keach

I've found postings of others having this problem but I haven't seen a
definitive answer. From my main form, I open child forms using
ShowDialog(). If they are closed in the normal fashion, all is well.

However, I have a session timer in my main form that logs the user out
after a period of inactivity and I close any child form that is open
by calling Form.Close().

When I do this, my application loses focus. Calling
Form.BringToFront() has no effect. I have worked around the problem
by calling SetForegroundWindow() on the main form immediately after
closing the child form but I don't think this should be happening.
Any ideas?

--Houston
 
G

Guest

I checked with one of our GUI developers on this issue, and below is her response. I hope it is helpful.

"This posting is provided "AS IS" with no warranties, and confers no rights."

Thanks
Richard Greenberg
...NET Compact Framework Team

Technical Response:

This sounds like a known issue, but there are a couple of things that might help the customer besides PInvoking to SetForegroundWindow.

Make sure the child forms don’t have BorderStyle=None. These are popup windows (with the WS_POPUP style), and have known z-order issues.

Make sure the child forms are only shown after the main form is visible (don’t do a ShowDialog from the contstructor of your main form that is fed into Application.Run).

If the customer would like to provide some repro code, I can look into a managed workaround that doesn’t involve PInvoking (I wrote some code based on what the customer stated below but I’m not seeing this repro).

(For V2 we’ve fixed a bunch of bugs around these issues, and now we’ve got Form.Activate, so moving forward this shouldn’t be an issue for people).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top