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
 
 
 
 
 
 
TitlePrint a rounded rectangle
DescriptionThis example shows how to print a rounded rectangle in Visual Basic 6. It uses the RoundRect API function.
Keywordsrounded rectangle, print, RoundRect
CategoriesGraphics, API
 
Thanks to Bob Ceccarelli.

The following code uses the RoundRect API function. The last two parameters give the width and height of an ellipse that defines the corner rounding. Note that a corner essentially uses a quarter of the ellipse so the rounded parts are half as wide and tall as the ellipse.

 
Private Sub cmdPrintVbStyle_Click()
Dim x1 As Long, y1 As Long, x2 As Long, y2 As Long, x3 As _
    Long, y3 As Long

    ' Print something to initialize the printer.
    Printer.CurrentX = 1440
    Printer.CurrentY = 1440
    Printer.Print " "

    ' Upper left corner.
    x1 = 1440 / Printer.TwipsPerPixelX          ' 1 inch
    y1 = 1440 / Printer.TwipsPerPixelY          ' 1 inch
    ' Lower right corner.
    x2 = 5 * 1440 / Printer.TwipsPerPixelX      ' 5 inches
    y2 = 3 * 1440 / Printer.TwipsPerPixelY      ' 3 inches
    ' Width and height of the corner ellipse.
    x3 = 1440 / Printer.TwipsPerPixelX          ' 1 inch
    y3 = 0.5 * 1440 / Printer.TwipsPerPixelY    ' 0.5 inch

    ' Draw the rounded rectangle.
    RoundRect Printer.hdc, x1, y1, x2, y2, x3, y3

    Printer.EndDoc
End Sub
 
Bob also includes some code that generates a print out using only API functions.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated