 |
X3ndou Level: Graduate
 Registered: 31-08-2004 Posts: 9
|
Sideways/Vertical Text
My program takes data from the user's input and puts it into a form which is printed. I want to make it print on the side, vertically, though. Is there any way to easily make a label sidways/vertical?
By the way, thanks to everyone who replied to my last post.
Thank you,
X3ndou
[Edited by X3ndou on 31-08-2004 at 09:29 PM GMT]
|
|
31-08-2004 at 09:29 PM |
|
|
X3ndou Level: Graduate
 Registered: 31-08-2004 Posts: 9
|
Re: Sideways/Vertical Text
I use VB5, and when I try to open the sample project included in the 3d text zip file an error comes up.
http://www.uploadthis.com/images/24/118.JPG
Is this because I us VB5?
Thanks,
X3ndou
[Edited by X3ndou on 31-08-2004 at 11:04 PM GMT]
|
|
31-08-2004 at 10:59 PM |
|
|
pc888 Level: Graduate
 Registered: 02-01-2004 Posts: 12
|
Re: Sideways/Vertical Text
I am not experienced with vb.old either.
However, in VB.net, you could 'draw' your text using GDI routine onto a background of your choice, and I assume using UNICODE characters. Since it will be your own code, you could write left to right, right to left, top to bottom, etc.
It is surprising that no one has not already come up with something.
|
|
01-09-2004 at 12:06 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Sideways/Vertical Text
TO draw some rotated text, next API's are all you need
CreateFont - created font will be used on forms/pictureboxes - objects that have device context
SelectObject - here you select created font to be default font on the device context
And then all yuo need is to set current position on the form
CurrentX=10
CurrentY=10
Print YourText |
After all is done select old font to be the default font on form, and delete font you have created to free resources
With more math, you could also draw curved text using this API's
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
01-09-2004 at 12:58 PM |
|
|
MikeG Level: Sage
 Registered: 21-02-2003 Posts: 54
|
Re: Sideways/Vertical Text
This code will add vertical text to a form.
Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal U As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) 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
Const ANSI_CHARSET As Long = 0
Const FF_DONTCARE As Long = 0
Const CLIP_LH_ANGLES As Long = &H10
Const CLIP_DEFAULT_PRECIS As Long = 0
Const OUT_TT_ONLY_PRECIS As Long = 7
Const PROOF_QUALITY As Long = 2
Const TRUETYPE_FONTTYPE As Long = &H4
Const p_WIDTH As Long = 12
Const p_HEIGHT As Long = 12
Private Sub RotateText(TheText As String, TheAngle As Long)
Dim NewFont As Long
Dim OldFont As Long
NewFont = CreateFont(p_HEIGHT, p_WIDTH, TheAngle, 0, FF_DONTCARE, 0, 0, 0, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_LH_ANGLES Or CLIP_DEFAULT_PRECIS, PROOF_QUALITY, TRUETYPE_FONTTYPE, "Arial")
OldFont = SelectObject(Me.hdc, NewFont)
Print TheText
NewFont = SelectObject(Me.hdc, OldFont)
DeleteObject NewFont
End Sub
Private Sub Form_Load()
Dim TheAngle As Long
Me.Show
CurrentX = 300
CurrentY = 150
TheAngle = -900
RotateText "This is a test", TheAngle 'angle in tenths of a degree 'PUT YOUR TEXT HERE
End Sub
|
[Edited by MikeG on 01-09-2004 at 11:36 AM GMT]
|
|
01-09-2004 at 07:23 PM |
|
|
|
|
 |
 |