dbTalk Databases Forums  

Releasing Modeless Forms

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Releasing Modeless Forms in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David A. Caruso
 
Posts: n/a

Default Releasing Modeless Forms - 08-01-2004 , 02:38 PM






I have a modeless form running. Then I click on another form (mMain)
that was opened previously and the modeless form goes to the
background. The question is, how do I release that modeless form now?
Is there no way to do it?

I tried this:

for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor

For some reason, I get this error "FORMS is not an object" (VFP 6). I
can however run the activate() method, but not the release() method. I
want to release this modeless form very much ...

David

Reply With Quote
  #2  
Old   
Stefan Wuebbe
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-02-2004 , 12:10 AM






Quote:
For some reason, I get this error "FORMS is not an object" (VFP 6).
The _screen.Forms collection loop is a good way I think.
If there is a Null reference among them, you can use TYPE()

Quote:
for nCount = 1 to _Screen.FormCount
if Type("_Screen.Forms(nCount).Name)")="C" AND ...
....

Or try the Name clause of the Do Form command and store
the references in properties of a persistent parent form or "form
manager" object
DO FORM customers.scx NAME goApp.oCustomers
&& and later
goApp.oCustomers.Release()


hth
-Stefan

"David A. Caruso" <caruso (AT) efn (DOT) org> schrieb
Quote:
I have a modeless form running. Then I click on another form (mMain)
that was opened previously and the modeless form goes to the
background. The question is, how do I release that modeless form now?
Is there no way to do it?

I tried this:

for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor

For some reason, I get this error "FORMS is not an object" (VFP 6). I
can however run the activate() method, but not the release() method. I
want to release this modeless form very much ...

David

Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-02-2004 , 01:18 AM



caruso (AT) efn (DOT) org (David A. Caruso) wrote:

Quote:
I have a modeless form running. Then I click on another form (mMain)
that was opened previously and the modeless form goes to the
background. The question is, how do I release that modeless form now?
Is there no way to do it?

I tried this:

for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor

For some reason, I get this error "FORMS is not an object" (VFP 6). I
can however run the activate() method, but not the release() method. I
want to release this modeless form very much ...
You are violating a principle here. I do not know that it has a
name, but the principle is that when you find something, you find it
in the last place you look for it. This is so, because once you find
it, you are supposed to stop looking for it. <G>

The problem is that the act of releasing the form changes the
value of _screen.formcount. AFAIK, loop control values are evaluated
for the loop only when it starts. Say you have three forms, and the
second is the one. After releasing that, there is no form three, yet
there will be a third iteration. Instead, try something like:

formindex=1
do while formindex<=_screen.formcount
if upper(alltrim(_screen.forms(formindex).Name))<>"MM AIN"
^^
I think this should be "=".
_screen.forms(formindex).release()
exit
endif
formindex=formindex+1
enddo

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #4  
Old   
lemmebe@frednwilma.com
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-02-2004 , 12:40 PM



On Sun, 01 Aug 2004 22:18:15 -0700, Gene Wirchenko <genew (AT) mail (DOT) ocis.net>
wrote:

Gene, I think you hit it bang on, but I think the simplest way to deal with
it is for him to change the line:

For nCount = 1 to _Screen.FormCount

to be

For nCount = _Screen.FormCount to 1 step -1

Alan

Quote:
caruso (AT) efn (DOT) org (David A. Caruso) wrote:

I have a modeless form running. Then I click on another form (mMain)
that was opened previously and the modeless form goes to the
background. The question is, how do I release that modeless form now?
Is there no way to do it?

I tried this:

for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor

For some reason, I get this error "FORMS is not an object" (VFP 6). I
can however run the activate() method, but not the release() method. I
want to release this modeless form very much ...

You are violating a principle here. I do not know that it has a
name, but the principle is that when you find something, you find it
in the last place you look for it. This is so, because once you find
it, you are supposed to stop looking for it. <G

The problem is that the act of releasing the form changes the
value of _screen.formcount. AFAIK, loop control values are evaluated
for the loop only when it starts. Say you have three forms, and the
second is the one. After releasing that, there is no form three, yet
there will be a third iteration. Instead, try something like:

formindex=1
do while formindex<=_screen.formcount
if upper(alltrim(_screen.forms(formindex).Name))<>"MM AIN"
^^
I think this should be "=".
_screen.forms(formindex).release()
exit
endif
formindex=formindex+1
enddo

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
My real address is alan at sprint dot ca
(with a 'p' on 'alan' making it 'alanp',
and no spaces). I'm sick of email spam.


Reply With Quote
  #5  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-02-2004 , 11:15 PM



lemmebe (AT) frednwilma (DOT) com wrote:

Quote:
On Sun, 01 Aug 2004 22:18:15 -0700, Gene Wirchenko <genew (AT) mail (DOT) ocis.net
wrote:

Gene, I think you hit it bang on, but I think the simplest way to deal with
it is for him to change the line:

For nCount = 1 to _Screen.FormCount

to be

For nCount = _Screen.FormCount to 1 step -1
Sure, but you will iterate through all of them. What if there is
only one? I prefer to quit looking.

[snipped previous]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #6  
Old   
lemmebe@frednwilma.com
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-03-2004 , 08:05 PM



On Mon, 02 Aug 2004 20:15:14 -0700, Gene Wirchenko <genew (AT) mail (DOT) ocis.net>
wrote:

I think I may have missed something. I thought, from his original post, that
the point was to release all windows _except_ "MMAIN".

(His original posted code)
Quote:
for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor
If so, don't you have to iterate through them all?

If that was not the point of the exercise, then yes, mea culpa.

Alan

Quote:
lemmebe (AT) frednwilma (DOT) com wrote:

On Sun, 01 Aug 2004 22:18:15 -0700, Gene Wirchenko <genew (AT) mail (DOT) ocis.net
wrote:

Gene, I think you hit it bang on, but I think the simplest way to deal with
it is for him to change the line:

For nCount = 1 to _Screen.FormCount

to be

For nCount = _Screen.FormCount to 1 step -1

Sure, but you will iterate through all of them. What if there is
only one? I prefer to quit looking.

[snipped previous]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
My real address is alan at sprint dot ca
(with a 'p' on 'alan' making it 'alanp',
and no spaces). I'm sick of email spam.


Reply With Quote
  #7  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Releasing Modeless Forms - 08-03-2004 , 08:48 PM



lemmebe (AT) frednwilma (DOT) com wrote:

Quote:
On Mon, 02 Aug 2004 20:15:14 -0700, Gene Wirchenko <genew (AT) mail (DOT) ocis.net
wrote:

I think I may have missed something. I thought, from his original post, that
the point was to release all windows _except_ "MMAIN".
Ah, no. He said:
The question is, how do I release that modeless form now?

Quote:
(His original posted code)
for nCount = 1 to _Screen.FormCount
if upper(alltrim(_Screen.Forms(nCount).Name)) <> "MMAIN"
_Screen.Forms(nCount).release()
endif
endfor
....but his code had that <>.

Quote:
If so, don't you have to iterate through them all?
Yes, you would.

Quote:
If that was not the point of the exercise, then yes, mea culpa.
Maybe, he was thinking that he might not know the name and he
only has the one form (MMAIN) besides the modeless form?

[snip]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.