Forms Created with Addobject method not have private session 
Author Message
 Forms Created with Addobject method not have private session

I'm using VFP80 Beta.
When I add a form into a custom object. Form not create a private session
automaticly.

Why?



Sat, 25 Jun 2005 18:22:42 GMT  
 Forms Created with Addobject method not have private session


Quote:
>I'm using VFP80 Beta.
>When I add a form into a custom object. Form not create a private session
>automaticly.

The default for the property DataSession has always been, and remains to be
0. So, if you want a different default, change your baseclass form (you do
have one, right?) property. Set up your options to use the base class
(Tools|Options|Forms|Form), then every time you create a form, it will use a
private datasession by default.

Did I understand the issue?

------------------------
Author of _Debugging_Visual_FoxPro_Applications_
http://www.hentzenwerke.com/catalogavailability/debugvfp.htm

What's new?
-----------
The Ed Leafe Fox Forum http://leafe.com/forum/



Sun, 26 Jun 2005 00:20:51 GMT  
 Forms Created with Addobject method not have private session
Hi, Fatih!
You wrote  on Tue, 7 Jan 2003 12:22:42 +0200:

 FD> I'm using VFP80 Beta.
 FD> When I add a form into a custom object. Form not create a private
 FD> session automaticly.

 FD> Why?

Why do you do it so way? Use

LOCAL loTmp
m.loTmp = CreateObject ("MyPDSFormClass")
This.AddProperty("oFormRef", m.loTmp)

I never tried to use AddObject for form objects.

BTW if you add any object to container, it will use DS this container use
(and container will use DS in which it was created).

WBR, Igor



Sun, 26 Jun 2005 04:59:16 GMT  
 Forms Created with Addobject method not have private session
Yes you are correct.
The default datasession for a form is "1" (btw not 0).
If you want a private datasession, just specify datasession = 2
in the form class declaration.

That's the way it is....

btw/ A defined form class will NOT have a dataenvironment added,
but since all forms have a datasession - in most cases a dataenvironment
may be extra bloat.

If you want a dataenvironment it must be added as a linked object
opposed to a directly added object.

e.g.

* Start of examples

oForm1 = createobject("MyForm1","Form w/ DE and cursor added in init()",10)
oForm2 = createobject("MyForm2","Form w/ DE, cursor, and relation added via
declarations",50)

oForm1.show
oForm2.show
read events
clear all    && Release the classes from memory

define class MyForm1 as form

  datasession = 2
  dataenvironment = null

  procedure init(lcFormName, lnPos)
    this.caption = lcFormName
    store lnPos to this.top, this.left

    * Have to add a generic DE this way, since
    * trying to add a DE in the properties declarations
    * section, trying to add a dataenvironment using
    * add object in a form's properties declaration
    * section will throw an error.

    * Add a generic DE
    this.dataenvironment = createobject("dataenvironment")

    this.dataenvironment.addobject("cursor1","cursor")
  endproc

  procedure destroy
    if _screen.formcount ==1
      clear events
    endif
  endproc

enddefine

* Or what I consider the better method since
* you have more granular control over the
* classes and contained methods.

define class MyForm2 as form

  datasession = 2
  * Add a custom DE
  dataenvironment =  createobject("C_CustomDE")

  procedure init(lcFormName, lnPos)
    this.caption = lcFormName
    store lnPos to this.top, this.left
  endproc

  procedure destroy
    if _screen.formcount ==1
      clear events
    endif
  endproc

enddefine

define class C_CustomDE as dataenvironment

  cursor1 = createobject("C_CustomCU")
  cursor2 = createobject("C_CustomCU")

   * Futher class implementation...

enddefine

define class C_CustomCU as cursor

  Relation1 = createobject("C_CustomRL")

  * Class implementation here

enddefine

define class C_CustomRL as relation

  * Class implementation here

enddefine

* End of examples

Darrell


Quote:
> I'm using VFP80 Beta.
> When I add a form into a custom object. Form not create a private session
> automaticly.

> Why?



Sat, 02 Jul 2005 03:34:20 GMT  
 Forms Created with Addobject method not have private session

Quote:

>The default datasession for a form is "1" (btw not 0).

Thanks for the correction.

------------------------
Author of _Debugging_Visual_FoxPro_Applications_
http://www.hentzenwerke.com/catalogavailability/debugvfp.htm

What's new?
-----------
The Ed Leafe Fox Forum http://http://opentech.leafe.com



Sat, 02 Jul 2005 03:48:17 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. user form property in a private data session form

2. private data sessions too private?

3. Not so private data session

4. Form's Private Data Session working with OLE to Excel

5. Multiple forms w/ private data sessions, and performance

6. How to access Private Data Session Form DataEnvironment

7. Multiple Forms, Private Data Sessions

8. Setting form's PRIVATE DATA SESSION ?

9. Determining Cursor Objects in Forms with private data sessions

10. Sharing tables in forms with private data session

11. Custom Form Method not visible from within ActiveX method

12. using form class w/o having to create formset

 

 
Powered by phpBB® Forum Software