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.

SpecialEffect, VisualEffect

The SpecialEffect property determines whether various controls have a 3-D look. For a few, it also determines the type of 3-D effect. VisualEffect, added in VFP 7, lets you raise or sink command buttons at runtime.

Usage

oObject.SpecialEffect = nEffect
nEffect = oObject.SpecialEffect

The values of nEffect are different for page frames, Containers and Controls than for other objects with this property. Most annoying, those three baseclasses use 2 for non-3-D while everyone else uses 1 for it. Why not make that one 0 and let other values represent other possibilities?

Visual FoxPro doesn’t offer a lot of choice in 3-D. Only page frames, Containers and Controls really have options. For page frames, when Tabs is .F., SpecialEffect is honored and interacts with BorderWidth to raise or sink the page by different amounts. The Container and Control classes also let you create raised and sunken effects in the same way.

For some objects such as page frames and Containers, the illusion used to make them look sunken and raised doesn't work very well once BorderWidth gets past 2 or 3. In particular, the color used to provide the brightening for the right and bottom edges of a sunken control or the left and top edges of a raised control is the default gray back color. You can prove this by changing the appropriate BackColor and noting that the BorderWidth is what you specified. We think a couple of shades lighter would be more effective. (We also note that, in VFP 3, this actually worked better for page frames than it does in versions 5 and later.)

For most of the controls that have SpecialEffect, it primarily affects the border of the object. For example, 3-D text boxes look sunken inside their borders. For option buttons and check boxes, SpecialEffect controls the actual graphical element that represents the control (the little circle or the check box itself).

In VFP 7, SpecialEffect has an additional value for the non-container controls. Specifying 2 (Hot Tracking) makes the controls flat until the mouse is over the control or, in most cases, it gets focus. (For option buttons and check boxes, you need to set Style to graphical in order to actually see the Hot Tracking effect.)

For a number of controls, when SpecialEffect is set to 2, only passing the mouse over the control raises it. The spinner remains flat when it receives focus. This is in contrast to the behavior of command buttons, which also stand out when they have focus.

As always, it would be nice if FoxPro.H contained mysterious numeric values like the settings for this property.

Example

* Use a sunken page frame.
This.Tabs = .F.
This.SpecialEffect = 1
This.BorderWidth = 5

Usage

cmdCommand.VisualEffect = nEffect

Parameter

Value

Meaning

nEffect

 

0

Leave the button as specified by SpecialEffect.

1

Give the button a raised appearance.

2

Give the button a sunken appearance.

VisualEffect gives you another way to change the appearance of buttons. It’s a fairly unusual property, in that it can be changed only at runtime.

We suspect that, most often, VisualEffect will be changed in the MouseEnter and MouseLeave events, also added in VFP 7. What VisualEffect provides that SpecialEffect doesn’t is the ability to make buttons sink.

There’s one conflict between SpecialEffect and VisualEffect. When SpecialEffect is set to 0—3-D, setting VisualEffect to 1–Raised has no effect. Guess the two effects cancel each either out. Actually, the issue is that the button is already raised, so telling it to appear raised doesn’t change it.

We are somewhat puzzled as to why this property applies only to command buttons. Why can’t we do this to other controls?

Example

* Sink a button – this might be in MouseEnter.
This.VisualEffect = 2

* Set it back to normal – this might be in MouseLeave.
This.VisualEffect = 0

See Also

BorderColor, BorderWidth, Container, Control, MouseEnter, MouseLeave, Page, PageFrame, Tabs