Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP5 - Toolbars & Toolbar Icon Problems
Message
 
 
To
10/11/1998 11:33:49
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00155593
Message ID:
00156284
Views:
70
Ed,

The only difference between:

this.AddObject( "moName", ... )

and

this.moName = CreateObject( ... )

is that AddObject causes the object to be added to the containership hierarchy. The object's .Parent property will point to the container it is in. And the object is added to the container's Objects/Controls[] collection. This has the added benefit that the object will be automatically removed during the container's destruct. There is no need to code a this.moName = .null. in the container.Destroy() when AddObject() is used.

In the application hierarchy you mention it doesn't matter if AddObject() or CreateObject() is used.

>I want to reconciliate these two points. It's natural reflection to have some kind of application hierarchy, and AddObject looks, first time only :), as better way, i.e. after you Add(object) something to oApp, you can refer it easily throughhout the application as oApp.MyObject1.... Also, using public variables as a way to promote CreateObject as alternative to AddObject, looks not so good, just because public variable is something out of OO world. However, if you instanciate objects linking them to properties of higher-level object (e.g. oApp.MyObject1=CreateObject("MyClass1")) then you can have both advantages: universality of CreateObject and OO application hierarchy.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform