scrolling text

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
Thanks, I've just sold your code on Ebay for $10.

Seriously, I have to go and get my hair cut, but I'll try it out later.

Regards - OHM#



Armin said:
"One Handed Man [ OHM# ]"
Come on then, post it for us Armin, I want to see it

q&d version:

Private m_StartTicks As Integer = Environment.TickCount
Private m_Bmp As New Bitmap( _
"G:\enterthepathwherethebitmapcanbefound\Bitmap1.bmp" _
)

Private Sub Timer1_Tick( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Timer1.Tick

UpdatePanel()
End Sub

Private Sub UpdatePanel()
Dim Diff As Integer
Dim g As Graphics
Diff = Environment.TickCount - m_StartTicks
g = Me.Panel1.CreateGraphics
g.DrawImage( _
m_Bmp, 0, 0, _
New Rectangle( _
0, Diff \ 20, Me.Panel1.Width, Me.Panel1.Height _
), GraphicsUnit.Pixel _
)
g.Dispose
'TODO: watch exceeding the bitmap's height and
'implement a loop
End Sub

Private Sub Panel1_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Panel1.Paint

UpdatePanel()
End Sub

and: timer1.interval=100


If you want it *really* smooth it occupies some more cpu power: (also
q&d)

Shared Sub main()
'I never use "Call", but "(New Form1).ShowDialog"
'does not work
Call (New Form1).ShowDialog()
End Sub

Public Shadows Sub ShowDialog()

Dim rect As Rectangle
Dim StartTicks As Integer

Me.Show()
Me.Refresh()

rect.Width = Me.Panel1.Width
rect.Height = Me.Panel1.Height

StartTicks = Environment.TickCount

Do
Dim Diff, Y As Integer
Dim g As Graphics
Diff = Environment.TickCount - StartTicks
rect.Y = Diff \ 20
'TODO: same todo as above...
g = Panel1.CreateGraphics
g.DrawImage(m_Bmp, 0, 0, rect, GraphicsUnit.Pixel)
g.Dispose()
Application.DoEvents()
Loop While Me.Created

End Sub

Regards - OHM# (e-mail address removed)
 
Hi Armin,

Taking that chalenge from OHM, I saw have to redraw my words, there is no
thread needed.

A timer will do that job as well, because the only thing you need is the
throwing of an event and that does a timer automaticly and the program will
not freeze.

But it can be done by it, but I would not do it either.

(I saw it once in this newsgroup before with a thread with no comments and
did not really investigate the problem, now I did).

:-)

Cor
 
"One Handed Man [ OHM# ]"
Thanks, I've just sold your code on Ebay for $10.
*stampingontheground*

Seriously, I have to go and get my hair cut, but I'll try it out
later.

Oh, I didn't know you really need it. (or I'd better say I know you don't
need it)

;-)
 
Looks Ok Armin. Quite a simple bit of code actually. I'll remember to store
this away somewhere for later use.

Regards - OHM#


Armin said:
"One Handed Man [ OHM# ]"
Come on then, post it for us Armin, I want to see it

q&d version:

Private m_StartTicks As Integer = Environment.TickCount
Private m_Bmp As New Bitmap( _
"G:\enterthepathwherethebitmapcanbefound\Bitmap1.bmp" _
)

Private Sub Timer1_Tick( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Timer1.Tick

UpdatePanel()
End Sub

Private Sub UpdatePanel()
Dim Diff As Integer
Dim g As Graphics
Diff = Environment.TickCount - m_StartTicks
g = Me.Panel1.CreateGraphics
g.DrawImage( _
m_Bmp, 0, 0, _
New Rectangle( _
0, Diff \ 20, Me.Panel1.Width, Me.Panel1.Height _
), GraphicsUnit.Pixel _
)
g.Dispose
'TODO: watch exceeding the bitmap's height and
'implement a loop
End Sub

Private Sub Panel1_Paint( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Panel1.Paint

UpdatePanel()
End Sub

and: timer1.interval=100


If you want it *really* smooth it occupies some more cpu power: (also
q&d)

Shared Sub main()
'I never use "Call", but "(New Form1).ShowDialog"
'does not work
Call (New Form1).ShowDialog()
End Sub

Public Shadows Sub ShowDialog()

Dim rect As Rectangle
Dim StartTicks As Integer

Me.Show()
Me.Refresh()

rect.Width = Me.Panel1.Width
rect.Height = Me.Panel1.Height

StartTicks = Environment.TickCount

Do
Dim Diff, Y As Integer
Dim g As Graphics
Diff = Environment.TickCount - StartTicks
rect.Y = Diff \ 20
'TODO: same todo as above...
g = Panel1.CreateGraphics
g.DrawImage(m_Bmp, 0, 0, rect, GraphicsUnit.Pixel)
g.Dispose()
Application.DoEvents()
Loop While Me.Created

End Sub

Regards - OHM# (e-mail address removed)
 
Thanks to you all - Armin, OHM, Cor, Herfried, as always - glad you had some
fun along the way!

Bernie
 
Back
Top