scrolling text

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
B

Bernie Yaeger

I'd like to develop scrolling text in an 'about' box, similar to the kind of
thing you see in lots of apps (eg photoshop). I could use flash to do this,
and I know how to, but I would like to know if I can do this in vb .net
only.

Thanks for any help.

Bernie Yaeger
 
set up a timed thead to scroll a label, this will create the motion by
incrementing the position of the label and not cause system hang ups because
it is in a sepreate thread
 
Brian Henry said:
set up a timed thead to scroll a label, this will create the motion
by incrementing the position of the label and not cause system hang
ups because it is in a sepreate thread

What is the benefit compared to a Timer (a WinForms timer)? Another thread
wouldn't make sense because the Label can not be accessed from the thread
anyway.
 
Bernie Yaeger said:
I'd like to develop scrolling text in an 'about' box, similar to the
kind of thing you see in lots of apps (eg photoshop). I could use
flash to do this, and I know how to, but I would like to know if I
can do this in vb .net only.

If the text isn't too large, I'd probably create a bitmap at design time or
at run time. Then enable a timer and at each tick draw the part of the
bitmap depending on the current time.
 
Hi Armin,
What is the benefit compared to a Timer (a WinForms timer)? Another thread
wouldn't make sense because the Label can not be accessed from the thread
anyway.

Looking to this problem, I think it can be done and Bearnie is someone who
does not care for
some extra code when he thinks it look nice.

When you make an extra thread, you can that let fire an event accoording to
a timer.
(You know I would do it in a way like this in the thread and not with a
timer)

\\\ a kind of psuedo
for i = 1 to 20
raise event 'public event
thread.sleep(500)
next
thread.abort
///

Than you can something with the label in the event thrown by this in your
mainpage, I think that can be look very nice.

Just a thought.
:-)
Cor
 
There ya go Bernie.

//AT CLASS MEMBER LEVEL
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32

Const WM_VSCROLL As Int32 = &H115

Const SB_LINEDOWN As Int32 = 1

Const SB_LINEUP As Int32 = 0


// IN YOUR ROUTINE

SendMessage(rtb2.Handle, WM_VSCROLL, SB_LINEUP, 0)

Regards - OHM


Bernie said:
I'd like to develop scrolling text in an 'about' box, similar to the
kind of thing you see in lots of apps (eg photoshop). I could use
flash to do this, and I know how to, but I would like to know if I
can do this in vb .net only.

Thanks for any help.

Bernie Yaeger

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


Looking to this problem, I think it can be done and Bearnie is
someone who does not care for
some extra code when he thinks it look nice.

When you make an extra thread, you can that let fire an event
accoording to a timer.
(You know I would do it in a way like this in the thread and not with
a timer)

\\\ a kind of psuedo
for i = 1 to 20
raise event 'public event
thread.sleep(500)
next
thread.abort
///

Than you can something with the label in the event thrown by this in
your mainpage, I think that can be look very nice.

Just a thought.
:-)
Cor

- Where is the difference to a System.Timers.Timer? It fires in a separate
thread without the need for you writing a loop.

- Where is the logical difference to a System.Windows.Forms.Timer? He would
have to call Invoke/BeginInvoke in the event handler anyway to update the
display. So, using a System.Windows.Forms.Timer is easier.

- Did I misunderstand? ;-)
 
"One Handed Man [ OHM# ]"
There ya go Bernie.

//AT CLASS MEMBER LEVEL
Private Declare Function SendMessage Lib "user32.dll" Alias
"SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal
wParam As Int32, ByVal lParam As Int32) As Int32

Const WM_VSCROLL As Int32 = &H115

Const SB_LINEDOWN As Int32 = 1

Const SB_LINEUP As Int32 = 0


// IN YOUR ROUTINE

SendMessage(rtb2.Handle, WM_VSCROLL, SB_LINEUP, 0)

Is there also a "smooth scrolling" version? ;-)
 
Come on then, post it for us Armin, I want to see it


OHM#

Armin said:
"One Handed Man [ OHM# ]"
There ya go Bernie.

//AT CLASS MEMBER LEVEL
Private Declare Function SendMessage Lib "user32.dll" Alias
"SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal
wParam As Int32, ByVal lParam As Int32) As Int32

Const WM_VSCROLL As Int32 = &H115

Const SB_LINEDOWN As Int32 = 1

Const SB_LINEUP As Int32 = 0


// IN YOUR ROUTINE

SendMessage(rtb2.Handle, WM_VSCROLL, SB_LINEUP, 0)

Is there also a "smooth scrolling" version? ;-)

Regards - OHM# (e-mail address removed)
 
- Where is the difference to a System.Timers.Timer? It fires in a separate
thread without the need for you writing a loop.
- Where is the logical difference to a System.Windows.Forms.Timer? He would
have to call Invoke/BeginInvoke in the event handler anyway to update the
display. So, using a System.Windows.Forms.Timer is easier.

I said I would do it that way, it is so few code and that thread only
exist one time.
I write that kind of code almost without thinking, while that is not with a
timer.

(By instance if a windows.forms.timer would work in a thread and if it is
threat save, for this I even would not take the time for that, because that
little routine does his job also very well I think).

Cor
 
Hi OHM,

I knew that that would come, and probably a very fine one.

Armin takes those chalenges.

Cor
 
He's probably searching furiously for a good example using google right now
!

LOL

Regards - OHM#
 
Cor said:
I knew that that would come, and probably a very fine one.

Armin takes those chalenges.

c'mon you (both) may have overlooked the -> ;-) <-

-> ;-) <-
 
A little competition is a healthy thing. It means that the OP at least gets
a variation on the answers and it put's some interest in the group, and we
get to see other ways of doing things.

It also helps us find out where useful information is because if we dont
know the answer, we have to search for it and thats a positive thing as
well.

I'm still a newbie here and will be for some considerable time to come, I
live to learn !


Regards - OHM#


Hi OHM,

I knew that that would come, and probably a very fine one.

Armin takes those chalenges.

Cor

Regards - OHM# (e-mail address removed)
 
One Handed Man said:
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
 
Back
Top