smhaig,
In each form, you can shadow the show method and determine if it should be
shown, or if an already open instance should be activated
The following example assumes you have a singleton collection class
FormCollection that maintains your 'open' forms
Also note that the form needs to be removed from the collection when the
form is closed
Public Class myForm
Private Shadows Sub Show()
'Check an instance of this form is not already open
Dim frm As Form
For each frm in FormCollection.GetInstance
If TypeOf frm is myForm Then
'The document is already open, so dispose this instance
Me.Dispose()
'Activate the original instance
frm.Activate()
'Exit the sub
Exit Sub
End If
Next
'Add the form to the collection
FormCollection.GetInstance.Add(Me)
'Show the form
MyBase.Show()
End Sub
Stephen
"smhaig" <an*******@discussions.microsoft.com> wrote in message
news:30****************************@phx.gbl...
Hi I did not go into it, I admit, as it is complicated.
I am actually putting info on all open forms in a list
collection of classes each of which holds info on each
form (such as the handle and the name of the form). In
the activate code I check to see if this form info class
is in the collection (it is put in the list in the
caller form between f = new form2 and f.show). If it is
not, then the form does not load.
Since I do not know anything about what goes on behind
the scenes I cannot say whether your code would work.
Hope that helps.
-----Original Message-----
When creating a new instance of your form you could call
a function whichperforms the test from the calling form (calling class)
so you would have:
dim fooForm as new SuperForm()
if fooForm.passesTests then
fooForm.show()
else
fooForm.dispose()
end if
Or something like that. Is this what you are asking?
Sorry if I missed thepoint.
-MC D