add custom method programmatically 
Author Message
 add custom method programmatically

It's easy to create your own properties and methods with custom class.
How could I add custom methods into form-derived class?
I can add custom proeprties this way:

define class myform as form
add object mytxtbox as textbox
procedure load
  this.addproperty("customprop")
endproc
procedure init
  thisform.mytxtbox.controlsource="thisform.customprop"
endproc
enddefine

But there is no form.addmethod() to custom methods.



Sat, 08 Nov 2003 09:30:55 GMT  
 add custom method programmatically
You can't do it at run-time, but to add a custom method in a programmatic
class is easy:

DEFINE CLASS myform AS Form
MyCustomProperty = "Initial value"    && You don't need .AddProperty to add
a custom property
                                                                && unless
you're trying to add it at run-time
FUNCTION MyCustomMethod
*
* Your code here
*
ENDFUNC
ENDDEFINE

--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.


Quote:
> It's easy to create your own properties and methods with custom class.
> How could I add custom methods into form-derived class?
> I can add custom proeprties this way:

> define class myform as form
> add object mytxtbox as textbox
> procedure load
>   this.addproperty("customprop")
> endproc
> procedure init
>   thisform.mytxtbox.controlsource="thisform.customprop"
> endproc
> enddefine

> But there is no form.addmethod() to custom methods.



Sat, 08 Nov 2003 10:56:50 GMT  
 add custom method programmatically
But I cannot add custom-properties the same way, right?
Foxpro would report a error initializing object
Quote:
> You can't do it at run-time, but to add a custom method in a programmatic
> class is easy:

> DEFINE CLASS myform AS Form
> MyCustomProperty = "Initial value"    && You don't need .AddProperty to add
> a custom property
>                                                                 && unless
> you're trying to add it at run-time
> FUNCTION MyCustomMethod



Sat, 08 Nov 2003 13:19:41 GMT  
 add custom method programmatically
sorry. should be protected custom properties.
Quote:

> But I cannot add custom-properties the same way, right?
> Foxpro would report a error initializing object



Sat, 08 Nov 2003 13:28:42 GMT  
 add custom method programmatically
it's my own problem I tried:

define class myform as form
protect myprop="xx"

which should have been

define class myform as form
protected myprop
myprop="xx"

Sorry. I think I made a similar mistake when I try
the custom method by definition.

Quote:

> sorry. should be protected custom properties.


> > But I cannot add custom-properties the same way, right?
> > Foxpro would report a error initializing object



Sat, 08 Nov 2003 13:47:59 GMT  
 add custom method programmatically
It looks like you've got the hang of it now.

--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.


Quote:
> it's my own problem I tried:

> define class myform as form
> protect myprop="xx"

> which should have been

> define class myform as form
> protected myprop
> myprop="xx"

> Sorry. I think I made a similar mistake when I try
> the custom method by definition.


> > sorry. should be protected custom properties.


> > > But I cannot add custom-properties the same way, right?
> > > Foxpro would report a error initializing object



Sun, 09 Nov 2003 01:17:41 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. add method code programmatically with grids

2. adding a custom method to a object

3. Custom Form Method not visible from within ActiveX method

4. How to programmatically change object event method ?

5. Custom editor for Methods

6. Defining methods in a custom PageFrame class

7. Custom class being lost when Release method called.

8. firing custom class methods at design time

9. Custom editor for Methods

10. removing custom methods

11. Adding a LostFocus Event To A Combobox Programmatically

12. Programmatically add code to forms?

 

 
Powered by phpBB® Forum Software