* TEST1.PRG PROCEDURE openfrmTest PUBLIC frmTest frmTest=CREATEOBJECT('form') WITH frmTest .ADDOBJECT('cntG1','subCC') .ADDOBJECT('cntG2','subCC') .cntG2.top=100 ENDWITH frmTest.SHOW CLEAR EVENTS CANCEL ENDPROC &&openfrmTest DEFINE CLASS anothersubCC as subCC PROCEDURE acarg(carg) subCC::AddColorToColors(carg) ENDPROC ENDDEFINE DEFINE CLASS subCC as container left=0 height=100 width=200 top=0 visible=.t. ADD OBJECT cboColors as subColors cboColors.left=20 cboColors.top=20 PROCEDURE AddColorToColors(carg) this.cboColors.AddListItem(carg) ENDPROC ENDDEFINE DEFINE CLASS subColors as ComboBox height=20 width=100 fontsize=8 columncount=1 columnwidths ="100" PROCEDURE init this.addlistitem("RED") this.addlistitem("WHITE") ENDPROC visible=.t. ENDDEFINEThen in the command window, I entered the following
* SET PROCEDURE TO TEST1 openfrmTest() && Displays the form oAdd=CREATEOBJECT('anothersubCC') && Object with superclass method v=oAdd.acarg("BLUE") && Add color "BLUE" to B-O-T-H combos on formMy hope was that "oAdd.acarg("BLUE")" would add the item to both combos. It didn't. When I add another copy of subCC to the form [.ADDOBJECT('cntG3','subCC')] (including frmTest.cntG3.left=100), cntG3 has BLUE in the combo. Is there a way to use inheritance to modify the subclassed collections.