Results 1 to 5 of 5

Thread: Diagonal text?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    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).]

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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



  3. #3
    New Member
    Join Date
    Sep 1999
    Posts
    9

    Post

    How do you for write a Text diagonally?

    Thanks in advance for help!

  4. #4
    New Member
    Join Date
    Sep 1999
    Posts
    9

    Post

    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!

  5. #5
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    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
  •  



Click Here to Expand Forum to Full Width