| Vertical Text with Alignment Options |
Applies To |
|
| OS: VB: |
NT, 9x, 2000 5, 6 |
|
Download... the project. (3 kb)
There is an API to do rotated text, but not vertical text. Luckily it is easy enough to do just by using the venerable Print method, which has managed to live on since the GWBASICA days. In addition, this example provides alignment options, which allows you to print vertical text aligned to the left, center and right. Screenshot below shows how the output works for each of the alignments.
As with anything on vbRad.com, the class works out of the box. You download it, pop it in to your project, set properties and it just works. Here is how easy this is: you set the canvas to print on (PictureBox or a Form), x and y positions (left and top, respectively), set the alignment and then just Print. If your form AutoRedraw property is set to False and you want your text to survive a window repaint, place the code into the Form_Paint event.
Private Sub btnPrint_Click()
Dim oVerticalText As cVerticalText
Me.Picture1.Cls
Set oVerticalText = New cVerticalText
With oVerticalText
Set .Canvas = Me.Picture1
.x = 1500
.y = 500
.Alignment = Align_Center
.PrintText "Whacky"
End With
Set oVerticalText = Nothing
End Sub
The download contains the class as well as a demo project. To use the class, simply drop it into
your project.
Download... the project. (3 kb).