Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: GDILine in Category Microsoft Visual Basic 6 : Graphics from Total Visual SourceBook

Class that draws a line, using Windows API GDI calls in VB6.

A line is a series of pixels drawn between two points on the screen. The routines in this class allow you to draw the line by calling the Windows API LineTo and MoveToEx functions.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CGDILine class
BorderColor Property Get the current value of the color used to draw the line
BorderWidth Property Get the current value of the BorderWidth used to draw the line
ForegroundMixMode Property Get the current value of the ForegroundMixMode property, which defines how colors from the pen and the colors in the existing image are to be combined. The value should be one of the enumerated raster op values exposed in EnumLineRasterOps, or the equivalent VBA/VB6 "DrawModeConstants", such as vbCopyPen, vbXorPen etc. See "Drawing Constants" in the VBA/VB6 on-line help.
PenStyle Property Get the value of the style used to draw the line. The value of this property should be set to one of the Windows API Pen Style constants (PS_SOLID, PS_DASHDOT etc.) which are exposed as EnumLinePenStyles constants in this class.
X1 Property Get the current location of the horizontal starting point of the line
X2 Property Get the current location of the horizontal ending point of the line
Y1 Property Get the current location of the vertical starting point of the line
Y2 Property Get the current location of the vertical ending point of the line
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings
Draw3DLine Method Draws two Lines on a selected device so that they create a 3D effect. The normal BorderColor property is not used with this method. Instead the two colors for the Lines are supplied as parameters
DrawLine Method Draw a line
TranslateVBColor Private Translates VBA/VB6 color constants for system colors into GDI equivalents. VBA/VB6 color constants, such as vbRed, vbBlue, or values returned using the QBColor() or RGB() functions, can be used directly for the color values used with Windows API calls. However, the VBA/VB6 color constants for system colors (vbButtonFace, vb3DShadow etc.) do not map correctly to those expected by Windows. This function accepts either form of constant and translates the value, if necessary, into the equivalent value expected by the Windows GDI subsystem.

Example Code for Using Class: GDILine

' Example of the CGDILine class
'
' To try this example, do the following:
' 1. Create a new form
' 2. Paste all the code from this example to the new form's module
' 3. Run the form and click on the background. Two lines are drawn, one
'    in red and one in blue, forming a cross.
' 4. A 3D line is drawn at the bottom of the form

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
  Dim GDILine As CGDILine
  Set GDILine = New CGDILine

  With GDILine

    ' Draw the horizontal red line
        .X1 = ScaleX(X, vbTwips, vbPixels) - 50
        .Y1 = ScaleY(Y, vbTwips, vbPixels)
        .X2 = ScaleX(X, vbTwips, vbPixels) + 50
        .Y2 = ScaleY(Y, vbTwips, vbPixels)

        .BorderColor = vbRed
        .BorderWidth = 1
        .DrawLine Me.hDC

    ' Draw the vertical blue line
        .X1 = ScaleX(X, vbTwips, vbPixels)
        .Y1 = ScaleY(Y, vbTwips, vbPixels) - 50
        .X2 = ScaleX(X, vbTwips, vbPixels)
        .Y2 = ScaleY(Y, vbTwips, vbPixels) + 50

        .BorderColor = vbBlue
        .DrawLine Me.hDC

    ' Draw the 3D line at the bottom of the form
        .X1 = 10
        .Y1 = ScaleX(Me.ScaleHeight, vbTwips, vbPixels) - 10
        .X2 = ScaleY(Me.ScaleWidth, vbTwips, vbPixels) - 10
        .Y2 = .Y1

        .Draw3DLine Me.hDC, vb3DShadow, vb3DHighlight

  End With

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources