Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add object to form in code
Message
From
08/01/2013 15:07:30
 
 
To
08/01/2013 14:11:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01561681
Message ID:
01561763
Views:
53
>>>>>Not quite sure how to do this.............
>>>>>
>>>>>I have a class (oJob) which is found in a prg (progs\job_generator.prg)
>>>>>
>>>>>I have a form. In the init of the form I want to add an instance of oJob as an object, not a property. The reason for this is that I would like oJob to be able reference properties on the form (this.parent.property)
>>>>>
>>>>>This isn't a critical issue for me (I have alternatives available that I'm sure would work) but I would like to know if this can be done and, if so, how.
>>>>>
>>>>>Thanks to all...............Rich
>>>>
>>>>Check the ADDOBJECT() command in the help - it's not too difficult to follow.
>>>
>>>Thanks for the response. For whatever reason I was having problems getting the parameters correct with AddObject() and wound up going with NewObject().
>>
>>Cool. One thing I thing you might have to do is the SET PROCEDURE TO and/or SET CLASSLIB TO (and there is pretty important ADDITIVE thing at the end of those statements you can use). Sound like you already got it all figured out so just an FYI... :)
>
>Thanks for this response. Just to make sure I understand correctly............
>
>In order to use form.AddObject() the prg/vcx file must have been included in the SET PROCEDURE/SET CLASSLIB statement. There is no way to pass it as a parameter to the AddObject() method. If I haven't done that I need to use form.NewObject()
>
>Thanks again...........Rich

If you use my NO Dynamic Snippet which comes with Thor, live is very simple. For instance type "no this.cntTimer cnt" and press the hot key you have assigned, in my case it's F5. Then you get a list of all classes in your current project and MRU which starts with cnt. Select the one you want, and you end up with the correct syntax, for instance
this.NewObject('cntTimer','cntmonth', 'novaformobjects.vcx')
NO also supports wild cards, so you don't have to remember the correct class name or in which classlib you stored it.
Previous
Reply
Map
View

Click here to load this message in the networking platform