form appear to scroll off the screen

Jimmythegreat

Member
Joined
Jul 19, 2006
Messages
17
Programming Experience
3-5
I have a timer set to 1ms. In this timer I have the following code:

VB.NET:
For i = 0 To loopin 'loopin is how many pixels per loop
  If Me.Width < xOrg Then 'xOrg is the forms width orginally
    Me.Width = Me.Width + 1
  Else
    scrollIn.Enabled = False
  End If
Next

This, as you can see, makes the form appear to scroll off the screen without moving the form (the form can't be moved for various reasons). There are four if's because with only one it goes way to slow and it cannot go below 1.

The problem is that when doing this the process uses 100% of my CPU. Is there anyway to clean this up and make it less demanding or completely change it to do the same effect. I also have another timer that makes the width grow that is executed at a differant time, so any code would also have to work with that.
 
Last edited by a moderator:
You don't need a Timer.
VB.NET:
Do Until Me.Width = xOrg
    Me.Width += 1
    Application.DoEvents()
Loop
 
That still seems to crank up the cpu usage. I got an idea this morning to make a panel slide over the form. This panel would be simi transparent on one side and fade to nontransparent on the other. The color of this panel would have to be the Transparent Key. How can I do this to the panel?

Thanks
JimmyTheGreat
 
Last edited:
Back
Top