On Tue, 24 Feb 2004 23:59:17 -0500, "TM" <no********@nothing.com>
wrote:
Is there any way to check if a form is already pen and if so set the focus
to it instead of opening another instance of that form ?
Thanks
It's not very easy. You could use Win API functions to enumerate all
windows and look for the window in question. (eg, EnumThreadWindows)
I had hoped that the static .NET function
System.Windows.Forms.Form.ActiveForm() would help me determine if ANY
forms were open besides the "main" form.
Unfortunately, I found it had a few quirks that limited its usefulness
for me:
(1) ActiveForm returns "Nothing" if the application does not
have focus.
(2) .. Returns "Nothing" if a non-application form is being
displayed (eg, a MsgBox() is open)
I think that you'll have to either resort to a windows enumeration or
building the functionality by adding code to implement the "singleton"
design pattern.
// CHRIS