Automatic fluid (in theory) resize of Windows Forms App
-
G'day, I am writing something to deal with logged multi-user access to our social media accounts, and what I want to do is add a second textbox when the message goes over the Twitter maximum - 140. What I have at the moment is a form with the controls anchored to their spot on the page. When the second textbox is needed, i call a timer with a 1ms trigger time to expand the size of the form by one 1 px until it's at the "large" size. The idea behind this is to have the second textbox slide down from behind the first one. However it is not fluid. Any ideas how I can speed it up or a better way of doing it? Thanks! Brendan
-
G'day, I am writing something to deal with logged multi-user access to our social media accounts, and what I want to do is add a second textbox when the message goes over the Twitter maximum - 140. What I have at the moment is a form with the controls anchored to their spot on the page. When the second textbox is needed, i call a timer with a 1ms trigger time to expand the size of the form by one 1 px until it's at the "large" size. The idea behind this is to have the second textbox slide down from behind the first one. However it is not fluid. Any ideas how I can speed it up or a better way of doing it? Thanks! Brendan
Slow the timer down. At the moment you are asking for 1000 frames per second animation - the drawing can't keep up with that rate so it looks "jerky". Change the interval to say 40 and try again. If may also be worth turning DoubleBuffered to true for the form - experiment. If you don't need it then don't do it as it slows drawing down.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Slow the timer down. At the moment you are asking for 1000 frames per second animation - the drawing can't keep up with that rate so it looks "jerky". Change the interval to say 40 and try again. If may also be worth turning DoubleBuffered to true for the form - experiment. If you don't need it then don't do it as it slows drawing down.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Is there a better way of doing it? I would like it to slide out smoothly, but also at a decent speed! Thanks, Brendan
Movies get played at 24 or 25 frames per second, which is faster than the human eye can discern, resulting in smooth films. So there is no point in having a timer period which is less than say 30 milliseconds. What you should do however, is in each repaint use the actual time, not the predicted or expected one, to calculate how the new frame should look; doing it that way you'd compensate for most of the timing jitter a Windows PC may experience. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum