Reputation: 2340
My form is displayed as TopMost on my application. The problem I have is that whenever I minimize my application or it loses focus, the form remains displaying. I want to be able to minimize my application or move to another and also hide or close my form. Once the application regains the focus, then unhide or open the form again.
Here is what I worked out on the form's closing event:
Private Sub frmNavigation_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Static Minimize As Boolean
If Minimize = True Then
e.Cancel = True
Me.Hide()
End If
End Sub
I tried using the same code in the applications WindowDeactivate
event but nothing happens.
Upvotes: 0
Views: 1122
Reputation: 2340
I was able to find an answer to the question. MSDN had an article on this very issue.
it can be found here: http://support.microsoft.com/kb/186908#appliesto
Upvotes: 0
Reputation: 54532
You do not show how you create the instance of your frmNavigation
. I am assuming that you are using the Show Method, so just use the version of Show that you pass in the top level window. That will assign the owner of the form, it will then stay on top of your Main Form and minimize and restore with it also. If this doesn't work please show how you are creating and showing your form.
frmNavigation.Show(Me)
Upvotes: 1