Visual Basic .NET » Windows Forms
Modal form doesn't have focus if parent window is inactive -- teeray --


I have a main windows form called frmMain and another form called frmLogin. I don't want frm Main to display until the user successfully

logins in. I call frmLogin.ShowModal from within the OnLoad event of frmMain. This displays frmLogin but the focus is not really on the form even though the cursor is blinking in the first textbox. If you start typing, it windows will type into what ever is behind frmLogin.
So I found this article that solved my focus problem:

http://west-wind.com/weblog/posts/2080.aspx 

However, now if I minimize a window that is behind frmLogin, frmLogin is closed and frmMain is activated. Here are the steps to re-create:
1. Launch an App (say NotePad)
2. Launch frmMain which is not shown yet but shows frmLogin 3. Minimize Notepad 4. frmLogin is closed and frmMain is activated
Anyone have a clue?
Thanks,

[Submit Comment]Home