none
Scroll Text Vertically RRS feed

  • Question

  • I want to add some sort of scrollable credits text to my application about form
    how can I do that using a label?

    I want to make it look like the one Kaspersky has for example
    included example below
    Saturday, February 27, 2010 9:55 PM

Answers

  • Hi Gwolf2u ,

    Try this code please.

    You do not have to add anything to the FORM.  :-)


    Regards,

    John

    Option Strict On
    Imports System.Environment
    Imports System.Drawing.Drawing2D
    Public Class Form1
    
        Friend WithEvents myTimer As New Timer
        Dim textToScroll As String = ""
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Me.DoubleBuffered = True
            'A larger value here will slow the vertical scroll down try 100
            'a snaller value will speed it up.>>
            myTimer.Interval = 10
            myTimer.Start()
    
            Dim sb As New System.Text.StringBuilder
            sb.Append("Coded by:" & NewLine)
            sb.Append("Mr J.A.Oliver")
            sb.Append(NewLine & NewLine)
            sb.Append("Co-producer:" & NewLine)
            sb.Append("Steven Spielberg")
            sb.Append(NewLine & NewLine)
            sb.Append("Producer:" & NewLine)
            sb.Append("George Lucas")
    
            textToScroll = sb.ToString
    
        End Sub
    
        Private Sub myTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles myTimer.Tick
    
            Me.Refresh()
    
        End Sub
    
        Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    
            Dim myFont As Font = New Font("Arial", 12)
            Dim mySizeF As SizeF = e.Graphics.MeasureString(textToScroll, myFont, Me.Width)
            Dim size As New Size(CInt(mySizeF.Width), CInt(mySizeF.Height))
    
            Dim xPos As Integer = (Me.Width - size.Width) \ 2
            Static yPos As Integer = Me.Height \ 2
    
            Dim myBrush As New SolidBrush(Color.Black)
            e.Graphics.DrawString(textToScroll, myFont, myBrush, xPos, yPos)
    
            yPos -= 1
            'This line causes the text to start again at the bottom of the FORM.>>
            If yPos < (-1 * size.Height) Then yPos = Me.Height
    
        End Sub
    End Class

    Saturday, February 27, 2010 11:24 PM
  • You can also use a panel with labels on it and move the panel

    Public Class Form1
    
        Dim P As Point
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            If Panel1.Bottom <= Me.ClientRectangle.Top Then
                P = New Point(0, Me.ClientRectangle.Height)
            End If
            P.Y -= 1
            Panel1.Location = P
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            P = New Point(0, Me.ClientRectangle.Height)
            Panel1.Location = P
        End Sub
    End Class

    Asgar
    Sunday, February 28, 2010 7:25 AM

All replies

  • That may be gif image or flash.   I did that in one of my program using flash

    kaymaf
    If that what you want, take it. If not, ignored it and no complain

    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    Saturday, February 27, 2010 10:27 PM
  • so any tips on doing this in flash then?
    Saturday, February 27, 2010 10:32 PM
  • so any tips on doing this in flash then?

    You have to go to flash forum to learn flash.  This is very simple to create without writing Actionscript, If you have adobe flash program or swishmax, you can create that using timeline.

    Try this link, for program that can generate the scrolling text for you.
    http://www.scriptocean.com/scrolling_text.html

    Do it yourself tutorial
    http://www.developingwebs.net/flash/mx_scrollingtextboxes.php
    http://kb2.adobe.com/cps/192/tn_19237.html


    or google search http://www.google.com/webhp?sourceid=navclient&ie=UTF-8#hl=en&source=hp&q=scrolling+text+vertically+in+flash&btnG=Google+Search&rlz=1R2GGLL_enUS360&aq=f&aqi=&aql=&oq=scrolling+text+vertically+in+flash&fp=62be43e2ee1279ac


    If you get your flash done, then you can add it to your program using shockwave object control in vb.net


    kaymaf
    If that what you want, take it. If not, ignored it and no complain

    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    Saturday, February 27, 2010 10:46 PM
  • Create an image (bitmap) of a suitable size to contain the whole text that you want to scroll.  Draw the text onto the bitmap.  Then use a timer and in the timer tick event copy the image to the form, specifiying a source rectangle that gradually moves down the image until it gets with the form height of the bottom, and then jumps back to the top. That will give you single pixel scrolling.

    http://www.vbdotnet.com.nu/scrolling_list_example.html
    Saturday, February 27, 2010 11:19 PM
  • Hi Gwolf2u ,

    Try this code please.

    You do not have to add anything to the FORM.  :-)


    Regards,

    John

    Option Strict On
    Imports System.Environment
    Imports System.Drawing.Drawing2D
    Public Class Form1
    
        Friend WithEvents myTimer As New Timer
        Dim textToScroll As String = ""
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Me.DoubleBuffered = True
            'A larger value here will slow the vertical scroll down try 100
            'a snaller value will speed it up.>>
            myTimer.Interval = 10
            myTimer.Start()
    
            Dim sb As New System.Text.StringBuilder
            sb.Append("Coded by:" & NewLine)
            sb.Append("Mr J.A.Oliver")
            sb.Append(NewLine & NewLine)
            sb.Append("Co-producer:" & NewLine)
            sb.Append("Steven Spielberg")
            sb.Append(NewLine & NewLine)
            sb.Append("Producer:" & NewLine)
            sb.Append("George Lucas")
    
            textToScroll = sb.ToString
    
        End Sub
    
        Private Sub myTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles myTimer.Tick
    
            Me.Refresh()
    
        End Sub
    
        Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    
            Dim myFont As Font = New Font("Arial", 12)
            Dim mySizeF As SizeF = e.Graphics.MeasureString(textToScroll, myFont, Me.Width)
            Dim size As New Size(CInt(mySizeF.Width), CInt(mySizeF.Height))
    
            Dim xPos As Integer = (Me.Width - size.Width) \ 2
            Static yPos As Integer = Me.Height \ 2
    
            Dim myBrush As New SolidBrush(Color.Black)
            e.Graphics.DrawString(textToScroll, myFont, myBrush, xPos, yPos)
    
            yPos -= 1
            'This line causes the text to start again at the bottom of the FORM.>>
            If yPos < (-1 * size.Height) Then yPos = Me.Height
    
        End Sub
    End Class

    Saturday, February 27, 2010 11:24 PM
  • You can also use a panel with labels on it and move the panel

    Public Class Form1
    
        Dim P As Point
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            If Panel1.Bottom <= Me.ClientRectangle.Top Then
                P = New Point(0, Me.ClientRectangle.Height)
            End If
            P.Y -= 1
            Panel1.Location = P
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            P = New Point(0, Me.ClientRectangle.Height)
            Panel1.Location = P
        End Sub
    End Class

    Asgar
    Sunday, February 28, 2010 7:25 AM
  • thanx it was very helpful to me
    Monday, July 28, 2014 12:22 PM