LPARAMETER oObject LOCAL oX, nIndex, nT, lFound FOR nIndex= 1 TO oObject.CONTROLCOUNT oX=oObject.CONTROLS[nIndex] DO CASE CASE oX.BASECLASS="Container" lFound=THISFORM.SetAddFocus(oX) CASE oX.BASECLASS="Pageframe" FOR nT=1 TO oX.PAGECOUNT IF THISFORM.SetAddFocus(oX.pages(nT)) oX.ActivePage=oX.Pages(nT).Pageorder lFound=.t. ENDIF ENDFOR CASE PEMSTATUS(oX,"SetFocusAtAdd",5) AND oX.SetFocusAtAdd oX.Setfocus lFound=.T. ENDCASE IF lFound EXIT ENDIF ENDFOR RETURN lFoundThe problem here is that .NET is static typed and the compiler wants to know the type of the object beeing passed. Now I do understand that if you define the parameter oObject as type object the passing of the parameter is not a problem since all visual classes inherit from this class.
If TypeOf oObject is IRodBinding Ctype(oObject,IRodBinding).BindingFunction Else......The problem with this approach is that it is not really an OO solution (in fact I've been burned for that at university when doing this when implementing a scalar math language inC++) as the OO language should provide a mechanism to make this unneccesary. The other problem with this is that a form can contain many different objecttypes which might or not might have the "SetFocusAtAdd" property. Implementing it this way would require a If TypeOf construct for each imaginary class on the form which contains the required property. This of course is not optimal as this code needs maintenance each time you use a new object type on your forms.