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.
oObject.SpecialEffect = nEffect
nEffect = oObject.SpecialEffectThe 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 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.)
As always, it would be nice if FoxPro.H contained mysterious numeric values like the settings for this property.
* Use a sunken page frame.
This.Tabs = .F.
This.SpecialEffect = 1
This.BorderWidth = 5cmdCommand.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?
* Sink a button – this might be in MouseEnter.
This.VisualEffect = 2
* Set it back to normal – this might be in MouseLeave.
This.VisualEffect = 0BorderColor, BorderWidth, Container, Control, MouseEnter, MouseLeave, Page, PageFrame, Tabs

