Getting parameters from inherited classes


Visual Foxpro allows you to create a class that inherits behavior from another class. This includes properties, events and methods. The base class could have a method like this:


 


PROCEDURE FooBar


LPARAMETERS strParm as string, nParm2 as Integer


 


When designing the subclass in the class designer, VFP will automatically show the inherited parameters. VFP6 obtained this information from the compiled base class info. However, the compiled code has no information on parameter cAse, which users understandably wanted to preserve. So it was changed for VFP7 to obtain the parameter info from the base class source code, which has the cAse information.


 


TrevorH has this repro code. Run it and you won’t see the base class parameters. Comment out the “REPLACE METHODS” line and you will.


 


LOCAL lcThisDir AS STRING


lcThisDir = ADDBS(JUSTPATH(SYS(16)))


CD (lcThisDir)


CLEAR ALL


CLEAR


IF VERSION(5) >= 800


      TRY


            CLEAR CLASSLIB ParamTstLib


            CLEAR CLASSLIB ParamTstLib2


      CATCH TO foo


      ENDTRY


ENDIF


ERASE ParamTst*.*


 


LOCAL laClass[1]


CREATE CLASS FormBase OF ParamTstLib AS FORM NOWAIT


_CLIPTEXT = ‘LaunchForm’


KEYBOARD ‘{ALT+C}M’


KEYBOARD ‘{CTRL+V}’


KEYBOARD ‘{ALT+A}’


KEYBOARD ‘{ALT+C}’


DOEVENTS


ASELOBJ( laClass, 1 )


laClass[1].WRITEMETHOD( ‘LaunchForm’, ‘LParameters tcClassID’ )


KEYBOARD ‘{CTRL+W}’


DOEVENTS


 


CLOSE ALL


USE ParamTstLib.VCX


GO 2


REPLACE METHODS WITH


CLOSE DATA ALL


COMPILE CLASSLIB ParamTstLib.VCX


 


CREATE CLASS FormChild OF ParamTstLib2 AS FormBase FROM ParamTstLib NOWAIT


KEYBOARD ‘{CTRL+W}’


DOEVENTS


MODIFY CLASS FormChild OF ParamTstLib2 METHOD LaunchForm NOWAIT

Comments (0)