 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Warrick Wilson Guest
|
Posted: Tue Jun 08, 2004 7:02 pm Post subject: How to "unscroll" a ScrollBy() call? |
|
|
I'm trying to create some moving text, like a marquee. Peter B. pointed me
at the ScrollBy() method that TWinControls have, and I was playing with the
following:
1. Create a Panel.
2. Create a TImage that's 3 times wider than the panel so that there's a
blank leader section, a section where I'll write some text, and a blank
trailer section.
3. On the TImage, write my text into the middle section.
4. Image.Parent := Panel;
So far, so good. That all works. My panel shows the blank leader section
initially.
4. Start a timer. On each timer event, do a Panel.ScrollBy(-2, 0) to move
the contents to the left.
5. Track how many pixels get shifted. Once we hit the start of the trailer
section, the message has scrolled across, and it is time to reset.
That works too. Nice and smooth.
BUT....
How do I reset? I initially tried doing a "reverse ScrollBy()", where I did
Panel.ScrollBy(200, 0) to undo 100 shifts of -2 to the left and reset my
shift counter. But for some reason that doesn't seem to put my graphic back
to the start of the blank leader section. What I do observe is my graphic
continuing to move left, until the blank trailer section slides off the left
side. The program keeps shifting something, but not my graphic.
I tried this with a ScrollBox, too, and setting the horizontal position to
0. Turns out that my ScrollBy() wasn't changing the horizontal position
anyway, so that didn't help.
Can anyone point out my mistake? Or point me to the reading I need to do to
understand this properly?
Thanks.
|
|
| Back to top |
|
 |
Tomaz Koritnik Guest
|
Posted: Wed Jun 09, 2004 12:56 pm Post subject: Re: How to "unscroll" a ScrollBy() call? |
|
|
Hi
Wouldn't it be easier to just draw text on temporary bitmap and then
draw bitmap to control at different X offsets?
regards
Tomaz
"Warrick Wilson" <warrickw (AT) mercuryonline (DOT) com> wrote
| Quote: | I'm trying to create some moving text, like a marquee. Peter B. pointed me
at the ScrollBy() method that TWinControls have, and I was playing with
the
following:
1. Create a Panel.
2. Create a TImage that's 3 times wider than the panel so that there's a
blank leader section, a section where I'll write some text, and a blank
trailer section.
3. On the TImage, write my text into the middle section.
4. Image.Parent := Panel;
So far, so good. That all works. My panel shows the blank leader section
initially.
4. Start a timer. On each timer event, do a Panel.ScrollBy(-2, 0) to move
the contents to the left.
5. Track how many pixels get shifted. Once we hit the start of the trailer
section, the message has scrolled across, and it is time to reset.
That works too. Nice and smooth.
BUT....
How do I reset? I initially tried doing a "reverse ScrollBy()", where I
did
Panel.ScrollBy(200, 0) to undo 100 shifts of -2 to the left and reset my
shift counter. But for some reason that doesn't seem to put my graphic
back
to the start of the blank leader section. What I do observe is my graphic
continuing to move left, until the blank trailer section slides off the
left
side. The program keeps shifting something, but not my graphic.
I tried this with a ScrollBox, too, and setting the horizontal position to
0. Turns out that my ScrollBy() wasn't changing the horizontal position
anyway, so that didn't help.
Can anyone point out my mistake? Or point me to the reading I need to do
to
understand this properly?
Thanks.
|
|
|
| Back to top |
|
 |
Warrick Wilson Guest
|
Posted: Wed Jun 09, 2004 3:42 pm Post subject: Re: How to "unscroll" a ScrollBy() call? |
|
|
This new approach was something suggested by Peter B of TeamB in another
thread in this forum regarding reducing flicker as the text bitmap was
redrawn:
"The key to prevent excessive flicker is to *not* redraw the complete banner
on
every step. Instead you use the ScrollWindow API function (or
TWincontrol.ScrollBy) to directly move the client area content one or two
pixels left and then you redraw only the one or two pixels column newly
exposed by this operation on the right. Do not use double-buffering with
this
approach, it will only get in the way."
So I have the ScrollBy stuff working OK, up until the point I scroll off the
end of the bitmap I created. Now I need to start adding stuff to the end to
fill in the piece that scrolls off. I was thinking that I could sort of
"unscroll" the bitmap, but it appears my understanding of what's happening
here is inadequate to get the thing working.
My next approach is going to be trying to copy a small rectangle of from the
source bitmap to the "uncovered" part of the panel after a certain portion
has scrolled by.
"Tomaz Koritnik" <nospam (AT) nospam (DOT) com> wrote
| Quote: | Hi
Wouldn't it be easier to just draw text on temporary bitmap and then
draw bitmap to control at different X offsets?
regards
Tomaz
"Warrick Wilson" <warrickw (AT) mercuryonline (DOT) com> wrote in message
news:40c60dcc$3 (AT) newsgroups (DOT) borland.com...
I'm trying to create some moving text, like a marquee. Peter B. pointed
me
at the ScrollBy() method that TWinControls have, and I was playing with
the
following:
1. Create a Panel.
2. Create a TImage that's 3 times wider than the panel so that there's a
blank leader section, a section where I'll write some text, and a blank
trailer section.
3. On the TImage, write my text into the middle section.
4. Image.Parent := Panel;
So far, so good. That all works. My panel shows the blank leader section
initially.
4. Start a timer. On each timer event, do a Panel.ScrollBy(-2, 0) to
move
the contents to the left.
5. Track how many pixels get shifted. Once we hit the start of the
trailer
section, the message has scrolled across, and it is time to reset.
That works too. Nice and smooth.
BUT....
How do I reset? I initially tried doing a "reverse ScrollBy()", where I
did
Panel.ScrollBy(200, 0) to undo 100 shifts of -2 to the left and reset my
shift counter. But for some reason that doesn't seem to put my graphic
back
to the start of the blank leader section. What I do observe is my
graphic
continuing to move left, until the blank trailer section slides off the
left
side. The program keeps shifting something, but not my graphic.
I tried this with a ScrollBox, too, and setting the horizontal position
to
0. Turns out that my ScrollBy() wasn't changing the horizontal position
anyway, so that didn't help.
Can anyone point out my mistake? Or point me to the reading I need to do
to
understand this properly?
Thanks.
|
|
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Wed Jun 09, 2004 6:06 pm Post subject: Re: How to "unscroll" a ScrollBy() call? |
|
|
In article <40c60dcc$3 (AT) newsgroups (DOT) borland.com>, Warrick Wilson wrote:
Image.Update;
In fact the way you are doing it now is not quite what i had in mind. You will
see problems if you cover your panel with another applications window and hide
that again, for instance. Everything that causes the image to redraw will
upend your scheme. In your setup you may try to simply move the image to the
left, by subtracting 2 from its Left property on each timer tick, instead of
using the Scrollby method.
Scrollby would be appropriate if you draw the text yourself on a paintbox, for
instance.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
|
|
| Back to top |
|
 |
RandomAccess Guest
|
Posted: Wed Jun 09, 2004 9:05 pm Post subject: Re: How to "unscroll" a ScrollBy() call? |
|
|
"Tomaz Koritnik" <nospam (AT) nospam (DOT) com> wrote
| Quote: | Hi
Wouldn't it be easier to just draw text on temporary bitmap and then
draw bitmap to control at different X offsets?
|
I wouldn't do it that way.
I would always draw the entire surface onto an offscreen bitmap. The text
would be drawn at the required offset at that time. Then simply blit the
image over to the control when it's ready.
Best regards
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|