Form Losing Focus

The Beginner

Member
Joined
Nov 25, 2009
Messages
6
Programming Experience
1-3
Hi,

I have two forms in an application. One is he background and then I show another keypad form called with the show() method (not showDialog) because I need to perform some validations on btn click.

The kepad has 10 buttons and an Enter Button. The problem is that the form keeps loosing focus (I checked this with a messagebox which keeps poping up once for focus=true and again for focus=false, it continuously keeps losing and gaining focus) so it does not process any keypress events untill i click somewhere on the form. I tried using me.focus() in form load event but to no avail. The forms TopMost property is also set to true.

Any suggestions...!:confused:
 
I agree with Hack, when a form is loaded with the show method, it automatically gets focus. There must be something on your first form that is running and grabbing focus. Do you have a timer on it, or a backgroundworker?
 
No, the calling form is just a blue background sceen and with no timer. Actually, it only calls and shows this form. But still I will check who gets the control when this form looses focus. I'll get back to you then...
Thanx
 
Are you calling the form by actually loading the form like this
frmKeypad.Show()
Or are you instantiating it like so
Using fKeypad As New frmKeypad
fKeypad.Show()
End Using

If so, from what I have experienced, you have to use ShowDialog because it calls it until the funciton says it loaded fine and closes. You can still do some validations with the second form using the showdialog, its just a little more complicated.
 
Back
Top