Print Page | Close Window

Rotate text on label?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=15743
Printed Date: 03 December 2024 at 12:35pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Rotate text on label?
Posted By: chrisABC
Subject: Rotate text on label?
Date Posted: 29 November 2009 at 8:20am
Is there any simple way (using CJ controls) to display a label with text rotated 90 degrees?
ie text going vertically down the page instead of horizontal?




-------------
Chris (Manchester, UK) -- www.abc6.co.uk ---- Using CodeJock ActiveX Suite 13.1.0 with Windows8, VB6 SP6



Replies:
Posted By: gibra
Date Posted: 01 December 2009 at 3:56am
I don't think make this possible.
 
You can only dispose text vertically (not rotate):
 

    With lblVertical
        .Alignment = xtpAlignCenter
        .Font.Name = "Tahoma"
        .Font.Size = 8
        .Height = 1650
        .Font.Bold = True
        .Width = 120
        .Caption = "V" & vbCr & "E" & vbCr & "R" & vbCr & "T" & vbCr & "I" & vbCr & "C" & vbCr & "A" & vbCr & "L"
    End With
 
 


-------------
gibra
CJ SuiteControl v: 13.x to 19.x
Windows 10 64bit
VS2019 - VB6.0 SP6
<a href="http://nuke.vbcorner.net/Home/tabid/36/language/en-US/Default.aspx" rel="nofollow">VS/VB 6.0 Installer v6.8


Posted By: Krog
Date Posted: 09 January 2010 at 12:38pm
There are many ways to do it...

In VB6 we can use the CreateFont API function. Check the following test project:

uploads/20100109_120027_RotateText.rar - 20100109_120027_RotateText.rar


Another way would to be printing the text in a PictureBox and then rotating it using GetPixel and SetPixel, but it is more difficult.


In VB.Net we can use this:
Quote Public Class Form1

    Public Sub RotateText(ByVal g As Graphics, ByVal MyFont As Font, ByVal MyText As String, ByVal Angle As Single, ByVal MyBrush As Brush, ByVal X As Single, ByVal Y As Single)

        While Angle > 360
            Angle = Angle - 360
        End While
        While Angle < 0
            Angle = Angle + 360
        End While

        ' Create a matrix and rotate it n degrees.
        Dim MyMatrix As New System.Drawing.Drawing2D.Matrix
        MyMatrix.Rotate(Angle, Drawing2D.MatrixOrder.Append)

        ' Draw the text to the screen after applying the transform.
        g.Transform = myMatrix
        g.DrawString(MyText, MyFont, MyBrush, X, Y)

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

        Dim NewFont = New Font("Arial", 12, FontStyle.Bold)

        ' Subroutine to alter text angle.
        RotateText(e.Graphics, NewFont, "Hello World", -45, Brushes.DarkBlue, 10, 100)

    End Sub
End Class


In VB.NET with XAML we can use also the RenderTransform or LayoutTransform.

The Codejock markup does not support these transformation functions.



-------------
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2
Language: Visual Basic 6 SP6



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net