Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Detecting open forms
Old
  (#1)
Raoul Watson
Guest
 
Posts: n/a
Default Detecting open forms - 06-04-2007, 10:31 AM

I have a form which should not be opened concurently with another form. Is
there a way to detect if a form is already open? I cannot use the statement:

If Form1.Visible = True then ..

because this statement actually will LOAD Form1 which is not what I want to
do.

I can of course use a global variable as a flag to indicate a form is open
and reset the flag on form unload and simply test for this flag, but any
alternative or idea is greatly appreciated.

Thanks and God Bless.
_Raoul


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Detecting open forms
Old
  (#2)
Karl E. Peterson
Guest
 
Posts: n/a
Default Re: Detecting open forms - 06-04-2007, 10:31 AM

Raoul Watson wrote:
> I have a form which should not be opened concurently with another
> form. Is there a way to detect if a form is already open? I cannot
> use the statement:
>
> If Form1.Visible = True then ..
>
> because this statement actually will LOAD Form1 which is not what I
> want to do.
>
> I can of course use a global variable as a flag to indicate a form is
> open and reset the flag on form unload and simply test for this flag,
> but any alternative or idea is greatly appreciated.


How's about looping the Forms collection, and looking for identifiable
characteristics?
--


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Detecting open forms
Old
  (#3)
Ralph
Guest
 
Posts: n/a
Default Re: Detecting open forms - 06-04-2007, 10:31 AM


"Raoul Watson" <EMAIL REMOVED> wrote in message
news:B7fXg.3279$HP.1206@trndny08...
> I have a form which should not be opened concurently with another form. Is
> there a way to detect if a form is already open? I cannot use the

statement:
>
> If Form1.Visible = True then ..
>
> because this statement actually will LOAD Form1 which is not what I want

to
> do.
>
> I can of course use a global variable as a flag to indicate a form is open
> and reset the flag on form unload and simply test for this flag, but any
> alternative or idea is greatly appreciated.
>


I rather prefer Karl's suggestion, but an alternative is to have each Form
define a common Mutex. Each form checks the Mutex on loading, if already
defined it exits.

-ralph


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Detecting open forms Thanks Karl & Ralph
Old
  (#4)
Raoul Watson
Guest
 
Posts: n/a
Default Re: Detecting open forms Thanks Karl & Ralph - 06-04-2007, 10:31 AM

Thanks Karl & Ralph for a good alternative..


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top