Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding button to toolbar at runtime
Message
De
25/04/2009 03:10:04
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Adding button to toolbar at runtime
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01396361
Message ID:
01396361
Vues:
109
Hi,

I need to create and show a toolbar at runtime from Load() method of a form, I code it the below way:
IF PEMSTATUS(_SCREEN, [oTestToolBar], 5)
	_SCREEN.oTestToolBar = NEWOBJECT([TestToolBar])
ELSE
	_SCREEN.ADDPROPERTY([oTestToolBar], NEWOBJECT([TestToolBar]))
ENDIF
_SCREEN.oTestToolBar.ADDOBJECT([TbBut1], [CommandButton])
_SCREEN.oTestToolBar.ADDOBJECT([TbBut2], [CommandButton])
_SCREEN.oTestToolBar.SHOW()
VFP help says
When you use AddObject to add an object to a container, the object's Visible property is set to False (.F.)
and it is TRUE, when I launch the form, the Toolbar appear on screen but no buttons is shown (as though it is empty).

So, I change the Show() method of my toolbar class - that is the TestToolBar as shown in the sample code above to
LOCAL oBut
FOR EACH oBut IN THIS.CONTROLS
	oBut.VISIBLE = .T.
ENDFOR
Then only the toolbar come up as expected with the 2 buttons added to it.
But I feel odd that I need the for loop in the show method to make the 2 buttons visible...

Question:
Am I doing it the correct way?
Any better suggestion?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform