Forcing a window to have focus

G

Guest

I have got an application that will present a custom dialog box to enter a username/password. Before it opens up it does other things, such as connects to the db. I decided to put a splash screen on the front of this, which opens up in a separate thread, and kills itself after a set time

Ever since I have started to display the splash screen, my logon window never gets the focus - even after the splash closes down. Both splash screen and logon window are called from another, non-visible (at startup) form.

The logon screen is set to be the topmost, and is a fixed toolbox window. I have tried calling frmLogon.Focus() and the app still doesn't get focus

How do I force this window to take focus

Thank

Martin
 
C

C# Learner

Martin said:
I have got an application that will present a custom dialog box to enter a username/password. Before it opens up it does other things, such as connects to the db. I decided to put a splash screen on the front of this, which opens up in a separate thread, and kills itself after a set time.

Ever since I have started to display the splash screen, my logon window never gets the focus - even after the splash closes down. Both splash screen and logon window are called from another, non-visible (at startup) form.

The logon screen is set to be the topmost, and is a fixed toolbox window. I have tried calling frmLogon.Focus() and the app still doesn't get focus.

How do I force this window to take focus.

I had a problem with not being able to get focus before, and I solved it
by calling:

form.Activate();
 
E

Elp

Martin Hazell said:
Ever since I have started to display the splash screen, my logon window
never gets the focus - even after the splash closes down. Both splash
screen and logon window are called from another, non-visible (at startup)
form.
The logon screen is set to be the topmost, and is a fixed toolbox window.
I have tried calling frmLogon.Focus() and the app still doesn't get focus.
How do I force this window to take focus.

Don't close the splash form before displaying the login form. Instead, in
the load event of the login form, call this.Activate() to give the focus to
the form and then close the splash form.
 
G

Guest

That worked a treat - it has been one of those annoying problems for a while now!

Cheer

Martin
 
J

Jeffrey Tan[MSFT]

Hi Martin,

I am glad the community's reply resolved your issue. Do you still have any
concern on it?

Please feel free to feedback, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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