sridhar412:
I just happened to be working on something similar all day.
If I understand your query correctly, you are trying to write method code to
controls at design time and maybe at run time.
* Some self back patting…
I created a database that resides at home ()+"cust_cntrls.dbc" which holds a number of tables for creating custom controls at design time. Basically a mini-framework.
I decided to write all the code for the custom controls and their associated method code as database stored procedures.
*
Now to your specifics:
First you have to get a reference to control(s) in question.
Second use the referenced controls’ .writemethod() i.e. oObjRef.WriteMethod(cMethodName,cMethodCode)
Since you said this will be a dynamic system, it will be easiest to use the _screen object to access the control(s).
i.e. _screen.forms[x].controls[x].writemethod(cMethod,cCode)
-or-
oObjRef = _screen.forms[x].controls[x]
oObjRef.writemethod(cMethod,cCode) && for code line brevity and readability
This won't work on instantiated (running) objects - only at design time.
VFP 7 allows you to write method code at run time I believe, but I'm still on VFP 6. Oh well...
Even if you’re are not using VFP7, here’s some code that generates a
form at on the fly, adds a textbox, and writes method code to the textbox’s click method:
create form Test nowait
_screen.forms[1].addobject("Text1","Textbox"

_screen.forms[1].text1.writemethod("Click","lnOne = this.value"
Voila!
Basically a run-time design environment, which may be, used for on-the-fly app customizations.
(note: there are other methods of getting a ref. Aselobj(), sys(1270) on a mouse down in a running program, etc., but you did specify dynamically generated and these other methods just don’t seem to fit the bill.)
Hope helps,
Darrell
'We all must do the hard bits so when we get bit we know where to bite'
