Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / October 2004



Tip: Looking for answers? Try searching our database.

Rotate a textbox or label

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JR - 30 Oct 2004 08:29 GMT
Hi,

Can someone help me.
I need a 90° rotated text on some of my forms. there for I need some code
that can do this.

Now I use a label convert the text in 1 char separated with a vbcrlf  and
make the label also 1 char width. That help but isn't still what I want

Jan
Mike Williams - 30 Oct 2004 11:58 GMT
> I need a 90° rotated text on some of my forms. there for I need some code
> that can do this.

Option Explicit
Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
"CreateFontIndirectA" (lpLogFont As LOGFONT_TYPE) 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 Const LF_FACESIZE = 32
Private Type LOGFONT_TYPE
 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 As String * LF_FACESIZE
End Type

Private Sub Command1_Click()
Dim font As LOGFONT_TYPE
Dim prevFont As Long, hFont As Long, ret As Long
font.lfEscapement = 900 ' tenths of a degree
font.lfFaceName = "Arial" + Chr$(0)
' Windows expects the font size to be in pixels and to
' be negative if you are specifying the character height
' you want. The following sets 12 point text.
font.lfHeight = (12 * -20) / Screen.TwipsPerPixelY
hFont = CreateFontIndirect(font)
prevFont = SelectObject(Me.hdc, hFont)
Me.ScaleMode = vbInches
Me.CurrentX = 1
Me.CurrentY = 2
Me.Print "Rotated Text"
' Clean up by restoring original font.
ret = SelectObject(Me.hdc, prevFont)
ret = DeleteObject(hFont)
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.