Results 1 to 2 of 2

Thread: How can I slide a long text?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    1

    How can I slide a long text?

    I don't know if this can be done by API, but anyway...
    I am making a very little application which consists in sliding a text. The text is in a RichTextBox and I need to control every pixel movement, so I can not use SendMessage because the minimum slide is 1 line of text. So, the only way I have found is by moving the control itself up and down, but the maximum height admitted by VB is not long enough for the lenght of the text. What can I do?
    I have also thought of translating the text into HTML and using a web-browser control to contain it (I have noticed that Internet Explorer lets you move the page pixel by pixel using the ScrollBar), but I have not found any control that gives its hWnd, needed by SendMessage.
    Could you help me? Thanks a lot.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Put this code in a Timer event. I've scrolled much longer lines than the one in this example using this routine:

    Const MyStr = "This program was written in Visual Basic 6.0 with an Access 2000 database."

    Static TopText As Integer
    Static TopLoaded As Boolean

    Dim Speed As Integer
    Dim NotShowing As Long

    'speed is one pixel per tick
    Speed = Screen.TwipsPerPixelY

    If Not TopLoaded Then
    'only set this once
    TopText = Picture2.ScaleHeight
    TopLoaded = True
    End If
    'clear picture box text
    Picture2.Cls

    'center the text about to be displayed
    Picture2.CurrentY = TopText
    Picture2.CurrentX = (Picture2.ScaleWidth \ 2) - (Picture2.TextWidth(MyStr) \ 2)

    'display text
    Picture2.Print MyStr

    'if text has moved past the top of the picture box
    'then start scrolling text from the bottom
    NotShowing = (TopText + Picture2.TextHeight(MyStr))
    If NotShowing < 0 Then
    TopText = Picture2.ScaleHeight
    Else
    'else continue moving text up
    TopText = TopText - Speed
    End If

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