Hi Sony,
Any time you drag an object onto a form, it will participate in the form's datasession. If you want a custom class to have it's own private DS, you have to at some point do This.Property = CREATEOBJECT("MySession") type of coding. I never do a SET DataSession TO in code. I always create the object I want to have a private DS inside a class based on a Form, FormSet, ToolBar, or Session.
Session.PRG
DEFINE CLASS MySession AS Session
PROCEDURE Create(Class, ClassLib)
RETURN CREATEOBJECT(m.Class, m.ClassLib)
ENDPROC
ENDDEFINE
Create a custom class, MyProcess and give it a Process method.
Create a custom class, VisualPrivateDS.
Give it a oSession property.
Give it a oProcess property.
Give it a Process method too.
Give it a ProcessClass and ProcessClassLib property. Set those to "MyProcess" and "MyProcessVCX".
In the Init of VisualPrivateDS do a
This.oSession = CREATEOBJECT("MySession")
This.oProcess = This.oSession.Create(This.ProcessClass, This.ProcessClassLib)
In the Process method do: This.oProcess.Process()
Now you can drop the class VisualPrivateDS onto a form and the process method will run in it's own DS. (Not that I've tested this code, but I do this sort of thing a lot.)
>Yes. But I won't be able to drag that onto any of my forms. I won't be able to say thisform.mynonVisualclass.process(), instead I have to create the object and call the method. It will work, yes.
Charlie