main logo
Subject: Re: Single instance forms?
Author: Jun M. Ramoneda
Posted: 2002/10/10 13:23:59
 
View Entire Thread
New Search


I seem to remember now that I did in fact encounter problems before. But I can't remember now what exactly the problem was and how I got around it. Let me do some tinkering and I'll get back to you as soon as I have an answer. I've made so many changes to the basic framework that I can't remember what I did with some of the problems. Serves me right for not documenting what I'm doing.

jun

<i><font color="#663300">Thanks Jun

I'll check it out again today.

<i><font color="#663300">Hello Bhavbhuti,
I've ran the same code on the Load and Init methods of my form class and I haven't encountered any problems. Maybe you have some other code in you Load or Init for your form classes.

jun


<i><font color="#663300">Hi Jun

I gave your code a try and got the following error twice for the 2nd instance:
Error #: 1925
Message: Unknown member OREGISTRY.
Line #: 5
Code: This.oRegistry.Add(toObject)
Method: objectregister
Object: frmmaccounts

and still the form's 2nd instance shows-up and the above error occurs again at the time of release of the 2nd instance. I tried putting the code in Init() [the 2nd instance of the form also closes the first instance] and also tried to allow the DODEFAULT() to be executed before the code in the load event but then I get 2 instances of the form.

Please let me know what I did wrong in the following code of Load Event:
LOCAL loForm

IF !THIS.lAllowMultipleInstances
loForm = goApp.oForms.GET(THIS.CLASS)

IF TYPE("loForm") == "O"
loForm.SHOW()

RETURN .F.
ENDIF
ENDIF

RETURN DODEFAULT()

<i><font color="#663300">In the Load event of your form class, add a new property (lAllowMultipleInstances) and put in the following code:

LOCAL loForm

IF NOT This.lAllowMultipleInstances
loForm = goApp.oForms.Get(This.Class)

IF TYPE('loForm') == 'O'
loForm.Show()
RETURN .F.
ENDIF
ENDIF

RETURN DODEFAULT()

<i><font color="#663300">CB seems to very nicely handle multiple instances of a form,
but what if I *don't* want to allow a form to have
multiple instances? How do I stop it please?

Many thanks</font></i>

</font></i>

</font></i>

</font></i>

</font></i>


 
©2002 Jun M. Ramoneda
<-- Prior Message New Search Next Message -->