Click to See Complete Forum and Search --> : Diagonal text?
QWERTY
Nov 5th, 1999, 01:38 AM
Maybe this will help Vb-World Tip (http://www.vb-world.net/tips/tip105.html)
------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-08-1999).]
Yonatan
Nov 5th, 1999, 01:48 AM
Try this:
Option Explicit
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub PrintRotatedText(ByVal Text As String, ByVal Degrees As Single, Optional ByVal X As Long = -1, Optional ByVal Y As Long = -1)
Dim lpFont As LOGFONT, hFont As Long, hOldFont As Long, lOldX As Long, lOldY As Long
lOldX = CurrentX: lOldY = CurrentY
If X = -1 Then X = CurrentX
If Y = -1 Then Y = CurrentY
lpFont.lfEscapement = Degrees * 10
lpFont.lfHeight = ScaleY(Font.Size * -20, ScaleMode, vbPixels)
hFont = CreateFontIndirect(lpFont)
hOldFont = SelectObject(hDC, hFont)
CurrentX = X: CurrentY = Y
Print Text
Call SelectObject(hDC, hOldFont)
Call DeleteObject(hFont)
End Sub
Parameters of PrintRotatedText:
Text: The text to print.
Degrees: The degrees to rotate it. May be a decimal fraction.
X, Y (Optional): The coordinates of where to print the text. If omitted, CurrentX and CurrentY are used.
Example:
Private Sub Form_Load()
AutoRedraw = True
Font.Size = 20
Call PrintRotatedText("Hello, world", 315, 400, 0)
' The above line prints the text "Hello, world" in point (400, 0) (twips). The text is rotated 315 degrees.
End Sub
------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
Tiny
Nov 5th, 1999, 11:58 AM
How do you for write a Text diagonally?
Thanks in advance for help!
Tiny
Nov 8th, 1999, 06:50 AM
Diagonal text and Printing???
I use procedure name « PrintRotatedText » of Yonatan!
The diagonal text display on screen correctly but nothing appears when printing.
I do not understand why?
I do this code for printing: form1.PrintForm.
Call PrintRotatedText("String", 315, 400, 0)
This line prints the text correctly at the diagonal on the screen, but for printing, nothing appears, why? How to settle this problem?
Thanks a lot for help!
smalig
Jan 28th, 2000, 04:17 AM
It's doesn't work because the code above use the Printer Object.
Test the code at my site :)
http://vbcode.webhostme.com/en/click.asp?id=143
Mit freundlichen Gruessen...
------------------
smalig
smalig@hotmail.com
http://vbcode.webhostme.com/
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.