Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding button to toolbar at runtime
Message
From
25/04/2009 03:10:04
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Adding button to toolbar at runtime
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01396361
Message ID:
01396361
Views:
111
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?
Next
Reply
Map
View

Click here to load this message in the networking platform