DoScroll

Visible

As I was going up the stair
I met a man who wasn't there

Hughes Mearns, The Psychoed

This property lets you turn things on and off visually. Now you see it, now you don't.

Usage

oObject.Visible = lIsVisible lIsVisible = oObject.Visible
Objects that are invisible can't receive focus. Makes sense to us—it would be really hard to tell that your cursor's on an object that isn't there.

Containers take their contents with them when you make them visible or invisible. That is, if you make a form invisible, all the controls disappear, too. When you make the form visible, you can see all the controls on it that were visible in the first place. The Visible property of the individual controls doesn't change, though. The same thing applies to all the other containers, like page frames, grids, command groups, and so on.

The interaction of Visible with grids is a little strange. Setting the grid's Visible to .F. acts as you'd expect—the grid disappears along with all its contents. But when you set Visible to .F. for a column, the column empties out but doesn't disappear. This doesn't surprise us—what does is that columns have a Visible property in the first place. Pages don't because it doesn't make sense to make a single page of a page frame disappear. Why does this make any more sense for columns?

Visible interacts with Sparse, so you can get some pretty weird results with the controls in columns, too. If Sparse is .T. and you set Visible .F. for the control in a column, the control disappears, but only when it has focus! To get the controls to disappear for all rows, you have to have Sparse set to .F., not that we can imagine why you'd want to do this.

On the whole, we don't think we'll be fiddling with Visible for members of grids too much.

Setting Visible to .T. for a form is not the same as showing the form. It doesn't activate the form, just makes it visible. Form.Show() is really a combination of setting Visible to .T. and activating the form.

When you add an object to a container with AddObject, it starts out with Visible set to .F., regardless of the way it's set in the class the object is based on. This lets you fiddle with the object before the user can see it. Get in the habit of following every AddObject call with Visible=.T. for the object. (It's not good enough to do it in the object's Init—it gets changed back after that.) Objects created with CreateObject() also start with Visible set to .F.

It's tempting to use Visible a lot to turn things on and off as context changes. Be careful how much you do this. Users can get really confused if a form looks different every time they look at it. Don't have buttons and the like disappearing unless you're into user-hostile interfaces. Use Enabled to make things inaccessible when they don't apply at the moment. Reserve twiddling Visible for cases like entire forms that don't apply for a particular record.

Example

* Make an object invisible because of a field value IF lIsMale    ThisFormSet.frmPregnancies.Visible = .F. ENDIF

See Also

Enabled, Hide, Show


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net