Re: Scrolling text in a stationary label help needed
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Sep 2006 09:51:19 +0100
<jcrouse1@xxxxxxxxxxx> wrote in message news:1158784589.191230.121660@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
One word "DUH!"
Don't worry about it John. If I had a pound for every mistake I've made I would be a rich man now ;-)
Anyways, here is where I am now. Seems to be
working properly. Thoughts and/or comments
Actually it's not working properly John. But don't worry about it. You're getting there. Firstly, I assume that you're setting the ScaleMode of both the Form and the Picture Box to vbPixels. If not then do so, otherwise the scroll will be very slow at the default twips setting.
The other thing, which is very important, is the fact that your code is still not actually running in the Timer, at least not in the way it is meant to. The idea (as you already know) is to scroll the text one pixel at a time. In other words, Print the text at position x and then wait for a short while (until the start of the next video frame in our case) and then Print the text again, this time at position x -1. Then repeat that for position x - 2 and then again for x - 3 and so on until you have eventually scrolled the text fully across the picture box, and then repeat the process. The idea is that you :
Clear the picture box to its background image
(Picture1.Cls) and perform a *single* Print
statement (Picture1.Print) at the current
x coordinate inside the Timer event. Then
decrement the x coordinate and check if
it is within limits and reset it if it is not.
You do this *just once* inside the Timer event. For the size of Picture Box and amount of text you are using the code in the timer will typically take much less than one tenth of a millisecond to perform the above task, even if your machine is set to the "smooth screen fonts" setting (and much less again if it is not). The Timer event code then finishes (it reaches the End Sub of the Timer event).
Your VB program now effectively does nothing at all, waiting for the next Timer event to fire. The only difference in our own requirements from the above is that we also perform an objDD.WaitForVerticalBlank inside the Timer event, so that we are actually in the event longer than we otherwise would be. But this isn't a problem because we have arranged the Timer period to be a little less than the typical period between individual video frames on a typical machine. (This part of course requires further explanation, because your code really needs to check the actual video frame rate on the machine on which it is running and then set up a suitable Timer period accordingly - using a higher resolution Timer than the VB one if necessary, but it will work fine on most system as it stands and I don't want to complicate things further until you've got the main part of it running correctly).
The "x coordinate" and the limit variables that the timer uses for printing should of course have a scope such that they can be "seen" by both the Timer event and by the rest of your code which calculates the initial value and start and end values in the first place, so they should in your case be "Form wide" variables.
First make sure your are using a ScaleMode of pixels for both the Form and the Picture Box (best to do this in code as the first two lines of your Form_Load event so that other people can see what you're doing when you post code). Then add the following line at the start of your Timer event code:
Private Sub Timer1_Timer()
Me.Caption = Val(Me.Caption) + 1
.. . . the rest of your Timer code
Run the program and leave it running for thirty seconds or so. Can you see what is happening, and why it is wrong? I could of course simply write code and post it for you, but I really do think it is better if you do it yourself.
Mike
.
- Follow-Ups:
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- References:
- Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: Dmitriy Antonov
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: Dmitriy Antonov
- Re: Scrolling text in a stationary label help needed
- From: Mike and Maureen
- Re: Scrolling text in a stationary label help needed
- From: Mike Williams
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: Mike Williams
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: Mike Williams
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Re: Scrolling text in a stationary label help needed
- From: Mike Williams
- Re: Scrolling text in a stationary label help needed
- From: jcrouse1
- Scrolling text in a stationary label help needed
- Prev by Date: Re: User Control Lose Focus
- Next by Date: Re: Running Isnumeric on Array Textbox
- Previous by thread: Re: Scrolling text in a stationary label help needed
- Next by thread: Re: Scrolling text in a stationary label help needed
- Index(es):
Relevant Pages
|