Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Khalil Shaddad
  Where is Khalil Shaddad?
 Beirut
 Lebanon
 Khalil Shaddad
 Tags
Subject: Preventing a form from running twice.
Thread ID: 22346 Message ID: 22346 # Views: 2 # Ratings: 0
Version: Visual FoxPro 7 Category: Forms
Date: Wednesday, April 16, 2003 8:52:13 AM         
   


Hi,
In order to prevent a from from running twice I am using the following code. It works perfectly but what I need is how to make this started form active knowing its name?
 llRetVal = .T.
 i = 0
 lcWindName = WCHILD("",0) && The "" must be a NULL or empty string

 * Loop through all open forms, and see if we have any that have the same
 * name as the one you want to open. (It exists in INIT() but is not yet
 * available.)

 DO WHILE !EMPTY(lcWindName)
    IF lcWindName = UPPER(this.name)
       i = i + 1
       IF i > 1
          llRetVal = .F.
          EXIT
       ENDIF
    ENDIF
    lcWindName = WCHILD("",1) && The "" must be a NULL or empty string
 ENDDO

 IF !llRetVal
 	MESSAGEBOX("Form Already Started")
???? 	Here I should set WindowState to 0 if this form was minimized????     How?
???? 	and I should Activate this form if not active????                                 How?
 	RETURN llRetVal && will return .F. preventing  the form from re-running.
 ENDIF
* continue loading the form as it is the first time.

Please help.
Khalil Shaddad (Lebanon)

COMPLETE THREAD

Preventing a form from running twice. Posted by Khalil Shaddad @ 4/16/2003 8:52:13 AM
RE: Preventing a form from running twice. Posted by Eric den Doop @ 4/16/2003 9:49:15 AM
RE: Preventing a form from running twice. Posted by Khalil Shaddad @ 4/16/2003 11:54:30 AM
RE: Preventing a form from running twice. Posted by Eric den Doop @ 4/16/2003 12:13:45 PM
Thanks. That was it. Posted by Khalil Shaddad @ 4/16/2003 12:59:53 PM