BorderColor, BorderStyle, BorderWidth

These properties control the borders of objects that have changeable borders. But some of the results are pretty strange.

Usage

oObject.BorderColor = nColor
nColor = oObject.BorderColor
oObject.BorderStyle = nStyle
nStyle = oObject.BorderStyle
oObject.BorderWidth = nWidth
nWidth = oObject.BorderWidth
BorderColor is available for a bunch of controls, but on most of them has no effect unless you set SpecialEffect to 1 (Plain). With 3-D effects, BorderColor is ignored. BorderColor determines the only color of a Line and the outside color of a Shape (the inner color comes from FillColor).As with DrawStyle and DrawWidth, there's a strange relationship between BorderStyle and BorderWidth. Settings of BorderStyle other than None or Single work only when BorderWidth is 1. When you use a wider border, it doesn't matter what value you give BorderStyle—you still get a single-line border.

In VFP 5 and later, with low color resolution (such as 256 colors), when a line or shape has a BorderWidth of 1, certain BorderColors show up wrong. The problem seems to occur with colors where the RGB values are some permutation of 0, 128, and 255. The same problem also occurs when BorderWidth of a line is greater than 1 and BorderStyle is set to 2, 3, 4 or 5.


For forms, BorderStyle controls more than appearance. Unless you use the default of 3 (Sizable), the form can't be resized using the mouse either at design-time or runtime. Although there are times you want to present fixed-size forms to users, it does make design a little difficult. We recommend you set BorderStyle in the Form's Init method if you need something other than the default. Borderless forms are finicky. Setting BorderStyle to 0 (None) isn't good enough. You have to also turn off all the stuff that appears along the top of the window. In VFP 6 and later, you can do that just by setting TitleBar to .F. In the older versions, Closable, ControlBox, MaxButton, MinButton and Movable must all be .F., and Caption has to be "", the empty string. If you miss any of those, you get a single-line border. It isn't until you turn off all those things that you can really see the difference between the three BorderStyles, other than 3-Sizable.As with DrawStyle, we can't make much sense of the "Inside Solid" border style.

Example

* Make a very un-Windows kind of form - maybe for an alert.
* Assume we have a reference, oForm, to the form. 
oForm.BorderStyle=1
oForm.Closable=.F.
oForm.ControlBox=.F.
oForm.MaxButton=.F.
oForm.MinButton=.F.
oForm.Movable=.F.
oForm.Caption=""
 
* Border stuff is fun with lines and shapes.
* First, create a form.
oForm=CREATEOBJECT("Form")
oForm.Show()
 
oForm.AddObject("CoolLine","Line")
oForm.CoolLine.Visible=.T.
oForm.CoolLine.Left=25
oForm.CoolLine.Top=25
oForm.CoolLine.Width=100
oForm.CoolLine.Height=150
oForm.CoolLine.BorderColor=GETCOLOR()  && Choose your favorite
oForm.CoolLine.BorderWidth=10
 
oForm.AddObject("DottyLine","Line")
oForm.DottyLine.Visible=.T.
oForm.DottyLine.Left=150
oForm.DottyLine.Top=40
oForm.DottyLine.Width=40
oForm.DottyLine.Height=25
oForm.DottyLine.BorderColor=GETCOLOR()  && Choose your favorite
oForm.DottyLine.BorderStyle=5
oForm.DottyLine.LineSlant="/"
 
oForm.AddObject("CoolShape","Shape")
oForm.CoolShape.Visible=.T.
oForm.CoolShape.Left=25
oForm.CoolShape.Top=100
oForm.CoolShape.Width=60
oForm.CoolShape.Height=50
oForm.CoolShape.BorderColor=GETCOLOR()  && Choose your favorite
oForm.CoolShape.BorderWidth=5

See Also

BackColor, DrawStyle, DrawWidth, FillColor, FillStyle, ForeColor, SpecialEffect, TitleBar


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .