there is some code posted in the vb.net codebank which i put there a while back showing how to unload all your Forms in .net, the basics of it are like this .....
the link for the thread in the codebank is this...VB Code:
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objType As Type() = Reflection.Assembly.GetExecutingAssembly.GetTypes() Dim x As Integer, i As Integer Try For x = LBound(objType) To UBound(objType) If Not objType(x).Name = Me.Name Then '/// make sure you dont unload this form yet. i = FindWindow(vbNullString, objType(x).Name) If Not i = 0 Then PostMessage(i, CInt(&H10), vbNullString, vbNullString) End If End If Next Catch ex As Exception MessageBox.Show("Oops, the following error occured:" & ex.Message) Finally MyBase.Close() '/// now that all the other forms are closed , unload this one. End Try End Sub
Close all Forms in .Net





Reply With Quote