Checking if a form lost focus

Joined
Apr 24, 2012
Messages
7
Programming Experience
Beginner
Hello,

I'm trying to make my program so that the user can at some point pop up a new form (with the main form staying in the background). While the new form is open, I want to make it impossible to go back to the main form without first closing the new one. Therefore I want the program to check if the new form has lost focus, and if so, force the focus back.

Any ideas how I can do this? I have tried the following, but it doesn't work:

Private Sub FormName_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Focus()
  End Sub
 
Rather than checking focus, just showdialog. That forces the form to close before returning to its parent.

VB.NET:
Dim xForm as new MyForm
xForm.ShowDialog()
 
Back
Top