Results 1 to 11 of 11

Thread: Scrolling Marquee (Text)

  1. #1

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Scrolling Marquee (Text)

    Here is a control I created to create a scrolling marquee effect.
    Attached Files Attached Files
    Last edited by Hack; Nov 10th, 2008 at 12:02 PM. Reason: Removed Compiled Code From Attachment
    "Don't try to be a great man. Just be a man and let history make its own judgement."

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Scrolling Marquee (Text)

    Thank you for your CodeBank submission.

    Per this CodeBank policy, I have edited your attachment and removed all compiled code.

    We welcome and appreciate all entries into our Codebank, but ask that source code only be included with anything attached.

    Thank you.

  3. #3
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    I like this control of yours very much. May I use your code in a school project I'm working on at the moment? I will, of course, credit you for the code, as well as citing this site as the location I got it from. Please note that I may need to make some minor changes and tweaks to make it blend in with the rest of my project, however the implementation and effect of the control will stay unchanged.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  4. #4

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: Scrolling Marquee (Text)

    Yeah, feel free to use it, and change it however you wish.
    "Don't try to be a great man. Just be a man and let history make its own judgement."

  5. #5
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    I'd like to report an issue with the control: when the scrolling direction is set to Left, the text "jumps" into view all at once instead of scrolling in. Could you please have a look?
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  6. #6

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: Scrolling Marquee (Text)

    Do you have a sample of the text you are "scrolling"?
    "Don't try to be a great man. Just be a man and let history make its own judgement."

  7. #7
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    It's "Loading your personal data..." I think.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  8. #8

    Thread Starter
    Hyperactive Member .NetNinja's Avatar
    Join Date
    Oct 2008
    Location
    USA
    Posts
    281

    Re: Scrolling Marquee (Text)

    Quote Originally Posted by obi1kenobi
    It's "Loading your personal data..." I think.
    I didn't have an issue with the above text. I will do further testing.

    You can take a look at the OnPaint event. That is what handles the drawing of the text.
    "Don't try to be a great man. Just be a man and let history make its own judgement."

  9. #9
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    Try switching the direction the text is scrolling once or twice. I'll have a look at the OnPaint method.
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  10. #10
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    I fixed the issue. Have a look at the original OnPaint:

    Code:
        Private Overloads Sub OnPaint(ByVal sender As Object, _
                                      ByVal e As PaintEventArgs)
    
            Dim str As String = m_MarqueeText
            Dim g As Graphics = e.Graphics
            Dim szf As SizeF
    
            g.SmoothingMode = SmoothingMode.HighQuality
            szf = g.MeasureString(m_MarqueeText, Me.Font)
    
            If m_LeftToRight = Direction.Right Then
                If startPosition > Me.Width Then
                    startPosition = -szf.Width
                Else
                    startPosition += 1
                End If
            ElseIf m_LeftToRight = Direction.Left Then
                If startPosition < -szf.Width Then
                    startPosition = szf.Width   'Because of this line, the text will start a width of the text to the right instead of from the right edge of the control
                Else
                    startPosition -= 1
                End If
            End If
            g.DrawString(m_MarqueeText, Me.Font, New SolidBrush(Me.ForeColor), startPosition, CSng(0 + (Me.Height / 2) - (szf.Height / 2)))
        End Sub
    Just replace the line:

    Code:
    startPosition = szf.Width
    with this one:

    Code:
    startPosition = Me.Width
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  11. #11
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: Scrolling Marquee (Text)

    I noticed that the control waits for the text to scroll out completely before starting to scroll it again... If the text is long, this may lead to a significant pause...

    It would be a good idea to start scrolling a new copy of the text as soon as the old one starts to move out of bounds... I'll try and do that next when I have the time...
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

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