On 2/21/2012 1:08 PM, Aaron Smith wrote:
In addition, each app that does use your shared object will get their
own copy to avoid inter-app mingling.
I left out an important part that makes the previous sentence true. If
you want everyone to have their own copy of the object, you have to
share a class "factory." Think of a class factory as a place that makes
objects. They are themselves very simple classes instantiated as
objects, then shared through SharedObjects.
For example, if you have a class like this:
Class MyTools
Public MyProperty
End Class
The factory for this class would look like:
Class MyToolsFactory
Public Function NewObject
Set NewObject= New MyTools
End Function
End Class
This factory is what you actually want to share through SharedObjects if
you want multiple apps to have their own copy. Sharing the factory means
that each app gets a copy of the object that creates the intended
object. Using the above classes, you would share like this:
If SharedObjects("com.myName.MyApp.MyTools", 0) Is Nothing Then
SharedObjects.Register "com.myName.MyApp.MyTools", New MyToolsFactory
End If
And then use the object like this:
Sub OnStateChange(objName, objState)
If objName = "com.MyName.MyApp.MyTools" Then
If objState Then
Set myToolsObj = SharedObjects(objName, 0).NewObject
' NewObject here is the public method of the MyToolsFactory
object that creates the MyTools object
End if
End If
End Sub
If Not myToolsObj Is Nothing Then
Speak myToolsObj.MyProperty
End If
Again, this is if you're sharing a class that should be unique to each
app that obtains a copy from SharedObjects. This is the method that the
toolkit uses.
Aaron
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.