Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sideways Label
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00799531
Message ID:
00813390
Views:
17
>I want to place a label on it's side, or have the text appear
>from top to bottom.
>
>I could make it do this:
>
>L
>A
>B
>E
>L
>
>
>but I would prefer the letters to be rotated
>
>Anyone know how?

Save this as a form... It does a bit more than you want, however, it has what you need.
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00800000&
   BorderStyle     =   5  
   ClientHeight    =   5460
   ClientLeft      =   60
   ClientTop       =   300
   ClientWidth     =   6045
   BeginProperty Font 
      Name            =   "Times New Roman"
      Size            =   9
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H00FF80FF&
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   364
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   403
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackColor       =   &H00000000&
      BackStyle       =   0  'Transparent
      Caption         =   "Resize me"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C000&
      Height          =   240
      Left            =   2310
      TabIndex        =   0
      Top             =   2475
      Visible         =   0   'False
      Width           =   1110
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

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          As String * 33
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private The_Text        As String
Private F               As LOGFONT
Private hPrevFont       As Long
Private hFont           As Long
Private Sleeptime       As Long
Private cx              As Single
Private cy              As Single
Private Theta           As Single
Private dTheta          As Single
Private xRadius         As Single
Private yRadius         As Single
Private i               As Integer
Private pi              As Single
Private Char            As String
Private Const SizeFact  As Single = 3  'play with this and sizefont to create the full ark
Private Const SizeFont  As Long = 10

Private Sub Form_Initialize()

    Sleeptime = 66
    FontSize = SizeFont
    
End Sub

Private Sub Form_Resize()

    The_Text = "UNIVERSAL THREAD ROTATING TEXT EXAMPLE...   "
    Cls
    Label1.Move (ScaleWidth - Label1.Width) / 2, (ScaleHeight - Label1.Height) / 2
    pi = 4 * Atn(1)
    cx = ScaleWidth / 2
    cy = ScaleHeight / 2
    Theta = pi
    dTheta = pi / TextWidth(The_Text)
    xRadius = ScaleWidth * 0.4
    yRadius = ScaleHeight * 0.4
    FontBold = True
    For i = 1 To Len(The_Text)
        F.lfEscapement = Theta * 3600 / pi / 2 - 950   'rotation angle, in tenths°. the additional 5 degrees tilt is to adjust the slight x/y offset
        F.lfFacename = FontName + Chr$(0)  'null terminated
        F.lfHeight = FontSize * SizeFact
        hFont = CreateFontIndirect(F)
        hPrevFont = SelectObject(hdc, hFont)
        Char = Mid$(The_Text, i, 1)
        CurrentX = cx + xRadius * Cos(Theta) - Cos(Theta) * TextHeight(Char) / SizeFact
        CurrentY = cy - yRadius * Sin(Theta) - Sin(Theta) * TextWidth(Char) / SizeFact
        Print Char
        Sleep Sleeptime
        Theta = Theta - dTheta * TextWidth(Char)
        hFont = SelectObject(hdc, hPrevFont)
        DeleteObject hFont
    Next i
    Sleeptime = 0
    Label1.Visible = True
    
End Sub
HTH,
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform