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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A way to redefine your class and make it a subclass of another class.

Classes and Objects

A way to redefine your class and make it a subclass of another class.

by  ramani  Posted    (Edited  )
*********************************************************
** Author : Ramani (Subramanian.G)
* FoxAcc Software / Winners Software
* ramani_g@yahoo.com
* Type : KB article
* Warranty : Nothing implied or explicit
* Last modified : 11 October, 2002
*********************************************************
[COLOR RED]
How to Introduce a Parent Class for your existing class .. or .. change your base class into a subclass of another class ?
[/color]
Time and again, we find the need to introduce, a class of our own which we feel should become a parent for many of the other classes.

For example, take the forms...
Some programmers who are new to VFP, create applications without subclassing the Base Classes and so each of the forms is based on the VFPs FormBase.

Then the need arises to introduce a common functionality to all the forms created.. or a group of forms.

So what we have to do, is introduce a FormBaseNew which is subclassed from FormBase and then make all the other related forms sub-class from this new FormBaseNew.

The way to do is...

[color blue]
Open The Project
Select Classes Tab
Create a new class .. Example.. a FormBaseNew based on the FormBase class.

Then.. Choose from the VFP Menu .. Tools..

Click on Class Browser..
Click OPEN (OPEN ICON)...
SELECT THE CLASS (.vcx) file required to be modified and open it

Then.. in the result window..
SELECT any of the Forms which need to be redefined...
Then Click on REDEFINE icon on that window...
Select the FormBaseNew as the class and proceed as it guides...
[/color]

You will notice that the classes are refined and the Selected form become the child of the FormBaseNew

Repeat the steps for all the forms which need to be modified so...

The same method can be used to modify the classes of other types..
[color red]
Remember to backup the project before doing any of these class modifications, or else, you could end up in trouble if some wrong clickings were made by you.
[/color]
*********************************************************
* EOF: ***.PRG
*********************************************************
Evaluate this to make others know how useful is this

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top