Line Method

See Also41RX951              Example3DPLOXQ>Low

Draws lines and rectangles on an object.

Syntax

[object.]Line [[Step](x1, y1)] - [Step](x2, y2) [,[color][,B[F]]]

Remarks

The Line method has these parts:

Part               Description

 

object            Object (non-MDI form, picture box, or Printer object) on which the line or rectangle is to be drawn.

Step              Keyword that specifies that the starting point coordinates are relative to the current graphics position, given by the CurrentX and CurrentY properties.

x1, y1            Single-precision values indicating the coordinates of the starting point for the line or rectangle.  The scale properties (ScaleMode, ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth) of object determine the unit of measure used.  If omitted, the line begins at the position indicated by CurrentX and CurrentY.

Step              Keyword that specifies that the end point coordinates are relative to the line starting point.

x2, y2            Single-precision values indicating the coordinates of the end point for the line to draw.  These coordinates are required.

color              Long integer value indicating the RGB color used to draw the line.  If omitted, the ForeColor property is used.  You can use the RGB function or QBColor function to specify the color.

B                   Option that causes a box to be drawn using the coordinates to specify opposite corners of the box.

F                   If the B option is used, the F option specifies that the box is filled with the same color used to draw the box.  You cannot use F without B.  If B is used without F, the box is filled with the current FillColor and FillStyle.  The default value for FillStyle is transparent.

 

When drawing lines that are connected, lines should be drawn so that subsequent lines begin at the end point of the previous line.

The width of the line drawn depends on the DrawWidth property.  The way a line or box is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.

When Line executes, CurrentX and CurrentY are set to the end point specified by the arguments.


See Also

CurrentX, CurrentY Properties9TOITD

DrawMode Property2ZATBSD

DrawStyle Property4PNS0NQ

DrawWidth PropertyMEUSKJ

FillColor PropertyL2TW7M

FillStyle Property2N3S7OE

ForeColor Property1W9T6JQ

Line ControlTW530P

QBColor FunctionNYS7SU

RGB FunctionLANRGB

ScaleHeight, ScaleWidth Properties3J8U7ZN

ScaleLeft, ScaleTop Properties138Z3ME

ScaleMode Property5SNY0BP

Shape Control9JZFLA


Line Method Example

The Line method example draws concentric boxes on a form.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim CX, CY, F, F1, F2, I              ' Declare variables

   ScaleMode = 3                         ' Set ScaleMode to pixels.

   CX = ScaleWidth / 2                   ' Get horizontal center.

   CY = ScaleHeight / 2                  ' Get vertical center.

   DrawWidth = 8                         ' Set DrawWidth.

   For I = 50 To 0 Step -2

      F = I / 50                         ' Perform interim

      F1 = 1 - F: F2 = 1 + F             ' calculations.

      Forecolor = QBColor(I Mod 15)      ' Set foreground color.

      Line (CX * F1, CY * F1)-(CX * F2, CY * F2), , BF

   Next I

   DoEvents                              ' Yield for other processing.

   If CY > CX Then                       ' Set DrawWidth.

      DrawWidth = ScaleWidth / 25

   Else

      DrawWidth = ScaleHeight / 25

   End If

   For I = 0 To 50 Step 2                ' Set up loop.

      F = I / 50                         ' Perform interim

      F1 = 1 - F: F2 = 1 + F             ' calculations.

      Line (CX * F1, CY)-(CX, CY * F1)   ' Draw upper-left.

      Line -(CX * F2, CY)                ' Draw upper-right.

      Line -(CX, CY * F2)                ' Draw lower-right.

      Line -(CX * F1, CY)                ' Draw lower-left.

      Forecolor = QBColor(I Mod 15)      ' Change color each time.

   Next I

   DoEvents                              ' Yield for other processing.

End Sub