Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDraw outlined text without using the API
Keywordsoutline, text, API
CategoriesGraphics
 

By Chris Wagg.

Subroutine OutlineText draws the text in the outline color shifted one pixel in every direction around the central position. It then draws the text again in the middle using the non-outline color.

 
' Draw an outline by drawing the text offset by
' one pixel in every direction. Then draw the text.
Private Sub OutlineText(ByVal obj As Object, ByVal txt As _
    String, ByVal start_x As Single, ByVal start_y As _
    Single, ByVal outline_color As OLE_COLOR, ByVal _
    text_color As OLE_COLOR)
Dim i As Integer
Dim j As Integer
Dim pixx As Single
Dim pixy As Single

    ' Draw the outline by drawing the text
    ' moved 1 pixel in all directions.
    pixx = obj.ScaleX(1, vbPixels, obj.ScaleMode)
    pixy = obj.ScaleY(1, vbPixels, obj.ScaleMode)
    obj.ForeColor = outline_color
    For i = -1 To 1
        For j = -1 To 1
            obj.CurrentX = start_x + i * pixx
            obj.CurrentY = start_y + j * pixy
            obj.Print txt
        Next j
    Next i

    ' Draw the text at its desired location.
    obj.ForeColor = text_color
    obj.CurrentX = start_y
    obj.CurrentY = start_x
    obj.Print txt
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated