Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Classes and VCX for the first time

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
MU
hi everyone,

i never had the opportunity and time to creat & work with classes and VCX ... but i read some articles on them a couple of days ago .. and it all seemed very interesting ... and now iam planning to give it a try ... and from what i have read and understood ... in very simple words ... to me it seemed more like procedures ( lines of code that can be called and used again and again ... like e.g. i have a invoicing form ... where the user enters the product description and after selecting an item it is entered into the grid below along with quantity and price etc .. etc... so this part could be put in a container and this container could be saved as a class .. and then this container or vcx could be droped into other forms like a purchase form or delivery note form to give the same functionality .. without the need to design the same excate thing over and over again ... right ?? !!! so am i getting this right .. guys ?? !!!!

thankx
vijay
 
Hi,

Whil Hentzen and others have written a lot of books on how to implement and use classes in VFP.

"Programming Visual Foxpro 3.0" is a very comprehensive book concerning this topic. It is a bit old, but it's still worth every cent.

Please do also have a look at the link below


hth

MK
 
... so this part could be put in a container and this container could be saved as a class .. and then this container or vcx could be droped into other forms like a purchase form or delivery note form to give the same functionality .. without the need to design the same excate thing over and over again ..

You've got it. That pretty well describes one of the reasons to create classes.

But note that the class doesn't have to be a container. It could be a single control. But a container that contains other controls is useful if those controls are designed to work together.

To take another example of that: I have a class that lets the user enter free text - like a memo field. They do that by typing into an edit box. There is also a button they can click that will expand the edit box to full screen. So the edit box and the button are designed to work together, and for that reason I put them in a container.

Also, classes work particularly well for generic functionality - not necessarily applied to a particular application or type of form. For example, I have a grid class that includes the ability to: sort the contents by clicking on a column header; to show alternate rows with a different background shading; and to highlight the entire row rather than a single cell. Because I like to use that functionality in all my apps, I have made it into a grid class. I can then just drop that onto any form, rather than using the native grid.

There are many books and articles about object orientation, but you can also learn by actually creating and using your own classes. Feel free to experiment, and ask questions when you get stuck.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I wouldn't call this feature of reusability "procedural", but like functions or procedures can be called from many places and so are written once and reused in many places, you can reuse classes, yes. That's only one aspect, but for sure not an unimportant one. There's much more benefit from inheritance and encapsulation.

But let's not deep dive too much here, before you get to these you can start using such reusable building blocks of containers to compose forms. Anyway, it would be somewhat redundant to use such a product choice container in too many places, I would rather make that a form on its own, but the idea of reusage is the same.

Bye, Olaf.
 
hi everyone ,

iam sitting and laughing at my self .... it's a shame ... all these years ... i never gave it a try .. looks like i have alot of catching up to do .... but i guess it's never too late . anyway thnakx to everyone for the input !

thankx
vijay
 
Dive right in. Once you've been through a few trial and error efforts you'll realize it's easier to DO than it is to describe. [dazed]

One of the earliest examples I used to use in teaching the move to OO is the progress bar we all "borrowed" from genscrn/genmenu back in the day. You could just copy/paste the code into your own code ... except it also needed a bunch of #DEFINEd constants and public memory variables so you had to remember to copy those too.

The other problem with that code was that it used DEFINE WINDOW so you could only ever have one of them at a time.

Converting that to a shape on a form vastly reduces the amount of code (it can be done in about a dozen lines of code) and it's completely self-contained for a better-looking apparatus, and since it's a form (as opposed to DEFINE WINDOW) you can run as many of them as you want at the same time.

It's more than JUST packaging of code, but packaging is certainly one of the benefits.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top