Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add method to a form programatically
Message
From
11/03/2009 00:08:23
 
 
To
22/04/1997 17:47:05
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00029315
Message ID:
01387043
Views:
153
Dragan ---

You said you had the Forms Designer Open?

If so, you can use WriteMethod ...

oForm.WriteMethod(cMethodName, cMethodCode)

where you get oForm using ASelObj()

Is this what you need?



>A bit of background first. I've been using all the versions of Fox since
>1989, and being grossly dissatisfied with genscrn, genmenu and other
>stuff, wrote a generator of my own. Presently, I'm in a process of
>migrating the generator to VFP, and have stumbled upon a problem; I've
>not found any solution to it in the FAQ, so:
>
>How do I add a new method to a form _programmatically_?
>
>My converter routine creates a form object, based on a form class
>defined somewhere in a .vcx, adds members reading the old-style .scx,
>assigns them properties etc. Having accomplished that, it saves to a
>.scx, calls the form designer to get some things beautified manually,
>and to call the builder to finish things up, i.e. to copy and convert
>the Valid, When and other routines from the old .scx into the new one's
>methods.
>
>When it comes to code snippets contained in memo fields, a problem
>arises when some snippet contains a "Procedure" or "Function" keyword,
>since a method snippet can not contain nested procedures. OK, let's
>extract the excess procedure into a new method, and let it's owner be
>the form itself. The catch-22 is that the only way to create a new
>method on the form is to activate "Form/New method" from the menu, and
>type the method's name manually, which is a pretty bad thing to do from
>a converter routine - it is intended to be single-pass, hands-off.
>
>I've seen that the people at VFP team have resorted to exactly the thing
>I wanted to avoid, when they wrote convert.app - they write text into
>methods' memos in the .scx file. Looks like a bit of a brute-force
>approach to me. I had been stuffing various things into memo fields for
>years (I might show up with some tiny miracles, if anyone's curious
>enough to take a look), and that practice seems far too non-oop to me.
>Besides, the aforesaid popup bar undoubtedly calls some system function,
>probably undocumented. Are there any chances that it may be revealed to
>us mortals?
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform