Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Show, Hide

These methods both activate and deactivate forms, formsets and toolbars, and make them visible or invisible. Show also lets you override a form’s WindowType property and indicate whether a form is modal or modeless.

Usage

oObject.Show( [ nWindowType ] )
oObject.Hide

Parameter

Value

Meaning

nWindowType

1

Make the form or formset modal.

2

Make the form or formset modeless.

Showing an object does two things: It makes it visible and it activates it, firing the Activate event along the way. Applying Hide to the object makes it invisible and deactivates it, firing Deactivate. Changing the Visible property has the same effect—some of the time. Or, to be more accurate, changing the Visible property has the same effect, if it’s done from a method of the form. But if Visible already had the value you assign, Activate or Deactivate doesn’t fire. That is, if Visible was .T. and you set it to .F., the object becomes invisible and Deactivate fires. But if Visible is .T. and you set it to .T., nothing happens at all. In addition, Activate and Deactivate don’t fire when you change Visible from another object, so the active status of the form doesn’t change.

Why are the values for nWindowType different from the ones for the WindowType property? Why is the sky blue? Why is the Pope Catholic? Just because.

nWindowType is ignored for toolbars, since there’s no such thing as a modal toolbar.

Making a form modal means that no other form can gain focus until you dispatch the one you’re working on. Similarly, with a modal formset, only the forms in the set are accessible—other forms won’t respond. Toolbars aren’t affected, though—you can access them even with a modal form or formset around. Frankly, we think it’s kind of odd, since much of the menu is disabled by a modal form and we tend to think of a toolbar as mouse shortcuts for the menu.

Example

oForm = CreateObject("Form")
oForm.Show()

* Clicking a particular button might hide one form in a formset
* The button's Click would contain:
ThisFormSet.frmMysterious.Hide()

See Also

Activate, Deactivate, Visible, WindowType