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.

Shape

No, this isn’t fitness advice. It’s a full-fledged control that displays rectangles, circles and shapes in between and lets them react when acted upon. Shapes can give regions of your interfaces “hotspots,” like the invisible buttons of FoxPro 2.x but with the fine control of a Visual FoxPro object.

Property

Value

Purpose

BackStyle

Numeric

Determines whether you can see through the shape.

BorderColor

Numeric

The color of the shape's border.

BorderStyle

Numeric

Specifies the type of border used for the shape. Options include dotted, dashed and so forth. Ignored unless BorderWidth is 1.

BorderWidth

Numeric

The width in pixels of the shape's border.

Curvature

Numeric

Determines the actual shape of the object. Set it to 0 for a rectangle, 99 for a circle or anything in between for various rounded rectangles.

DrawMode

Numeric

Determines how the shape's colors interact with the colors of the objects beneath it.

FillColor

Numeric

The color of the shape's interior.

FillStyle

Numeric

The type of pattern used for the interior of the shape. Various types of lines and "hatching" are available.

Shapes respond to the usual events like Click and DragOver, and have the run-of-the-mill methods like Drag and Move. Starting in VFP 7, they also have MouseEnter and MouseLeave. All of this is a big improvement over FoxPro 2.x, where shapes (and lines) were just so much dead space on your form. The ability to manipulate properties at runtime makes these so much better than what you can make with the form’s drawing methods. Consider a shape with Transparent BackStyle and no border for invisible regions you can place over controls (using ZOrder) to catch mouse movements without having to write the code for every control; Ted used this trick to make a read-only, unclickable grid. Nick Neklioudov carried it much further to provide exquisite control over events—see the December 2000 issue of FoxPro Advisor.

Example

* Here's the red circle that's used in so many examples of OOP.
* It responds when clicked.
DEFINE CLASS RedCircle AS Shape

   Curvature = 90
   BorderColor = RGB(255,0,0)
   FillColor = RGB(255,0,0)
   FillStyle = 0

   PROCEDURE Click
      WAIT WINDOW "Who's that knocking on my door?"
   ENDPROC
ENDDEFINE

See Also

BackStyle, BorderColor, BorderStyle, BorderWidth, Box, Circle, Curvature, DrawMode, FillColor, FillStyle, Line, Line Method, MouseEnter, MouseLeave