TN-S09
1/17/1997

Pepperwhite TechNote

Changing the rendering attributes of a line or polygon

Here's an easy technique for changing the color of a UserDefinedLine at runtime. This same technique can be used to alter any of the rendering attributes of user defined lines and polygons as well as to make any given line / polygon visible or invisible.

Topics Covered

  1. Automatic Redraw
  2. No Vertices Required
  3. Microsoft Visual Basic Examples

Automatic Redraw

The control monitors the attributes of your line and polygon features. If you alter any of them, the feature will be redrawn. Forcing a redraw after changing a rendering attribute is not required.

No Verticies Required

When using GetLine and SetLine, it is not necessary to pass the array of latitude, longitude vertices unless you are modifying them. If you are only altering appearance properties, you can pass a null address pointer in place of the array. The language specific examples below illustrate the passing of a null pointer.

The generalized technique shown in the following examples performs the following steps:

  1. Use GetLine to retrieve the existing attributes of the line/polygon
  2. Alter any of the following attributes:
    • Flags - especially pwVISIBLE
    • DrawColor
    • DrawStyle
    • DrawWeight
    • FillColor
    • FillStyle
    • Caption
  3. Use SetLine to the updated attributes to the control

If one or more lines/polygons will frequently have their appearance changed during the course of execution of your program, it is advisable to have these user defined features rendered in the animation layer to minimize the refresh delay. Refer to any of the animated polygon sample programs to see this technique in action. Rendering in the animation layer is accomplished by setting the pwANIMATE Flag in the CreateLine function.

Visual Basic sample code

In the following code sample, the control is notified that you are not including vertex data by passing a null address pointer in place of the latitude, longitude array. In Microsoft Visual Basic, this is accomplished with the syntax:

    ByVal 0&
Sub ChangeLineColor(LineID as Long, NewColor as Long)

    Dim LineAttributes As UserDefinedLine
    Dim Result as Integer

    ' Get the line's existing attributes
    LineAttributes.ID = LineID
    Result = GetLine(Map1, ldf.ID, ByVal 0&, 0)

    ' Change one or more of them
    LineAttributes.DrawColor = pwYELLOW

    ' Set the line's new attributes
    Result = SetLine(Map1, ldf.ID, ByVal 0&)

End Sub

Back to article index | Home
Do you have a suggestion or correction?

Copyright © 1997 Pepperwhite. All rights reserved.

609/983-2884    PO Box 1084     Medford NJ USA     08055