|
-
Nov 5th, 1999, 02:38 AM
#1
Thread Starter
Fanatic Member
Maybe this will help Vb-World Tip
------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-08-1999).]
-
Nov 5th, 1999, 02:48 AM
#2
Guru
Try this:
Code:
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: [email protected]
ICQ: 19552879
-
Nov 5th, 1999, 12:58 PM
#3
New Member
How do you for write a Text diagonally?
Thanks in advance for help!
-
Nov 8th, 1999, 07:50 AM
#4
New Member
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!
-
Jan 28th, 2000, 05:17 AM
#5
Addicted Member
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
[email protected]
http://vbcode.webhostme.com/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|