' Draw some text on the object.
Private Sub DrawText(obj As Object)
Const THE_TEXT = "Rotated text"
Const FONT_SIZE = 20
Const PRINTER_SCALE = 4
Dim wid As Single
Dim angle As Long
Dim new_font As Long
Dim old_font As Long
' Create a font rotated 360 degrees.
new_font = CreateFont( _
FONT_SIZE * PRINTER_SCALE, 0, 3600, 0, _
FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, _
OUT_TT_ONLY_PRECIS, _
CLIP_LH_ANGLES Or CLIP_DEFAULT_PRECIS, _
PROOF_QUALITY, TRUETYPE_FONTTYPE, _
"Times New Roman")
' See how big the text is.
old_font = SelectObject(picHidden.hdc, new_font)
wid = 2 * (picHidden.TextWidth(THE_TEXT) + 120)
picHidden.Width = wid
picHidden.Height = wid
picHidden.AutoRedraw = True
picHidden.Cls
' Destroy the new font.
SelectObject picHidden.hdc, old_font
DeleteObject new_font
' Draw the rotated text.
For angle = 300 To 3600 Step 300
' Create the rotated font.
new_font = CreateFont( _
FONT_SIZE * PRINTER_SCALE, 0, angle, 0, _
FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, _
OUT_TT_ONLY_PRECIS, _
CLIP_LH_ANGLES Or CLIP_DEFAULT_PRECIS, _
PROOF_QUALITY, TRUETYPE_FONTTYPE, _
"Times New Roman")
SelectObject picHidden.hdc, new_font
' Print the text.
picHidden.CurrentX = wid / 2
picHidden.CurrentY = wid / 2
picHidden.Print THE_TEXT
' Destroy the new font.
SelectObject picHidden.hdc, old_font
DeleteObject new_font
Next angle
' Make picHidden's image permanent.
picHidden.Picture = picHidden.Image
' Copy the result onto the object.
obj.PaintPicture picHidden.Picture, _
0, 0, wid / PRINTER_SCALE, wid / PRINTER_SCALE, _
0, 0, wid, wid
End Sub
|