|
Home > Archive > FoxPro Help and Support > December 2005 > Hook in class designer, when creating a new property
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Hook in class designer, when creating a new property
|
|
| bzamfir@gmail.com 2005-12-29, 9:24 am |
| Hi,
I create a class, used for developers.
What I want is, when a developer uses my class and add a new property,
to automatically create the assign method for it (with default code)
This is required for the functionality of my class (I bind the assign
method for each property to a generic method, to accomplish the result
I need)
Is there any way to do this?
Thank you
Regards,
Bogdan Zamfir
| |
| Michel Roy 2005-12-29, 11:24 am |
| When you bind to a property, you should bind to it directly and not to the
Assign method. If you bind directly to the Assign method, be aware that
Access and Assign methods are marked as Protected and are not visible except
within the class.
Note If you bind to a property that has an Assign method, the delegate
method might trigger twice. The first time is when the property assignment
call is made. The second time is when the property is actually set, within
the Assign method, to the parameter that is passed. The delegate method
should be aware of this possibility.
"bzamfir@gmail.com" wrote:
> Hi,
>
> I create a class, used for developers.
> What I want is, when a developer uses my class and add a new property,
> to automatically create the assign method for it (with default code)
> This is required for the functionality of my class (I bind the assign
> method for each property to a generic method, to accomplish the result
> I need)
>
> Is there any way to do this?
>
> Thank you
>
> Regards,
> Bogdan Zamfir
>
>
| |
| Michel Roy 2005-12-29, 1:24 pm |
| this is the ugliest/stupidous code ever, but you can try it
yy = CREATEOBJECT("uu")
yy.added1 = "abcdefg"
yy.added2 = "ooeioeo"
SUSPEND
DEFINE CLASS uu as oo && add custom properties to base class
added1 = ""
added2 = ""
ENDDEFINE
DEFINE CLASS oo as custom && base class
PROCEDURE Init
LOCAL ARRAY aaa(1)
ii = AMEMBERS(aaa,This,1,
"U")
this.addproperty("CustomProp",CREATEOBJECT("Collection"))
FOR nn = 1 TO ii
IF aaa(nn,2) = "Prop"
this.CustomProp.Add(CREATEOBJECT("textbox"))
This.CustomProp.Item(This.CustomProp.Count).Name = aaa(nn,1)+"_ngissa"
BINDEVENT(This,aaa(n
n,1),This.CustomProp.Item(This.CustomProp.Count),"value",1)
BINDEVENT(This.CustomProp.Item(This.CustomProp.Count),"value",this,"propassign",1)
ENDIF
next
ENDPROC
PROCEDURE propassign
LOCAL ARRAY laevent(1)
ii = AEVENTS(laevent,0)
qq = laevent(1).Name
ww = STREXTRACT(qq,"","_ngissa") && assign backwards
? TEXTMERGE("<<PADR(ww,20)>> set to <<EVALUATE('this.'+ww)>>")
ENDPROC
ENDDEFINE
"bzamfir@gmail.com" wrote:
> Hi,
>
> I create a class, used for developers.
> What I want is, when a developer uses my class and add a new property,
> to automatically create the assign method for it (with default code)
> This is required for the functionality of my class (I bind the assign
> method for each property to a generic method, to accomplish the result
> I need)
>
> Is there any way to do this?
>
> Thank you
>
> Regards,
> Bogdan Zamfir
>
>
| |
| Dan Freeman 2005-12-29, 1:24 pm |
| If you're using VFP 9, you can intercept menu choices (like "New Property")
through the Intellisense engine. There's even a replacement New
Method/Property dialog that ships with VFP. (It's far superior to the native
dialog.)
DO (_samples + "solution\solution.app")
Navigate to "New in VFP 9" and look for "Foxcode Menu Scripts". There's a
button that will install everything for you. You'll find the source for this
dialog in xsource.zip, so you can make it do anything you like when someone
adds a new property.
Dan
bzamfir@gmail.com wrote:
> Hi,
>
> I create a class, used for developers.
> What I want is, when a developer uses my class and add a new property,
> to automatically create the assign method for it (with default code)
> This is required for the functionality of my class (I bind the assign
> method for each property to a generic method, to accomplish the result
> I need)
>
> Is there any way to do this?
>
> Thank you
>
> Regards,
> Bogdan Zamfir
| |
| bzamfir@gmail.com 2005-12-29, 8:25 pm |
| Thank you. I'll check that
Regards,
Bogdan
|
|
|
|
|