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

Inherited Methods

Status
Not open for further replies.

bigj

Programmer
Apr 12, 2000
7
CA
Does any one know how to modify a method which has been inherited by a new class after sub classing ? I subclassed one set of the navbuttons in Visual Fox 6.0. I want to add code to the my new class so that when the user reaches the top of the table and clicks the top button I could advise him that he has reach the top of the table. If I add code to the click event of this button it only overrides the code which comes from the parent class. When I use the class browser to edit parent or child class my code is not saved.
 
In the subclassed method--

If you want the inherited code to run first:

DoDefault()
Your code here

If you want your code first, then the inherited behavior:

Your code here
DoDefault()

 
Are you sure you're trying to modify the proper copy of your code? And why are you modifying it in the class browser? You should find the class library for the class you want to change and pull it up in your project (add it if necessary). But if you're like me and sometimes make copies of your main subclassed class library, then you may add the wrong one and make changes which won't affect your actual objects. So be sure to check the class your object is created from. Dave Dardinger
 
HI

YOu can put the code in your setme fuction or some such function where the navigation buttons are passing values and doing the activity.

You can add this code...

IF EOF() OR recno() = reccount()
WAIT WINDOW "You are at the last record" Nowait
ENDIF
IF BOF() OR RECNO() = 1
WAIT WINDOW "You are at the First record" Nowait
ENDIF
DODEFAULT()

some such code can be added suitably.
The same code can be added in your ...
previous button click event
or
top button click event
or
last button click event
or
next button click event

Hope this helps you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
WHen you are using a dodefault() there are some rules of thumb you should consider.

When the superclass method has a parameter statement, always pass the parameter to the dodefault(), unless you are fully aware of the results when not passed or are doing this on purpose.

Most methods have a return value, in Fox method by default return .T. when no return value is given in the superclass method.

So for instance, when the superclass method would be:

PROEDURE ExampleMethod
LPARAMETERS tcCode
LOCAL llRetVal
*- Code, bla, bla, bla

RETURN llRetVal
ENDPROC

your subclass method could be:

PROECDURE Examplemethod && within the subclass
LPARAMETERS tcCode
LOCAL llRetVal

llRetVal = DODEFAULT(tcCode)

IF llRetVal
*- The new code, or extra code
ENDIF

RETURN llRetVal
ENDPROC


Most of the time if you do not pass the parameter, this could cause some unpredictable results that if you are not aware of the ommission of passing the parameter, can cost a lot of time tracking down.

HTH,

Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top