Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best method to determine if form is active
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00514365
Message ID:
00514387
Views:
9
>Hi,
>
>I am attempting to run some code that will determine if a form is open and nothing I have tried seems to work. What I want to do is run a procedure from my menu program to determine if a form is in the _screen collection. If it is (i.e. if the form is active but minimized) , then I just want to maximize the form and give it focus - otherwise I want to load the form. Any ideas?

Allan,
What have you tried? The following (or something like it) should work:
lparameters tcCaption
local oform
oform = .NULL.
With _Screen
   for lxx = 1 to .FormCount
      if upper(.Forms[lxx].BaseClass) = "FORM" ;
         and upper(.Forms[lxx].Caption) = upper(tcCaption) then
         oform = .Forms[lxx]
         exit
      endif
   endfor
Endwith

return oform
In your calling code, pass the caption in. If it finds it, it will return an object reference to that form and you can call the Show method. If it returns a NULL value, then you know to issue a DO FORM.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform