Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with superclass inheritence
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Help with superclass inheritence
Divers
Thread ID:
00811701
Message ID:
00811701
Vues:
40
I have a project that will have several combos on the form with the same items it the list. When changes are made to another control, the items in all the combos will need to be changed or modified. One way would have been to address the change to each combo seperately. My hope is that one of us with a better knowledge of how to use superclass methods to change inherited proprties could help.

Fist, there is a PRG procedure file (Test1) with the classes
* 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.
ENDDEFINE 
Then 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 form
My 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.

Any help appreciated.
Imagination is more important than knowledge
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform