![]() |
|
[.NET] Easily animate your custom controls with mutimedia timer - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Easily animate your custom controls with mutimedia timer (/showthread.php?tid=5541623) |
Easily animate your custom controls with mutimedia timer - hfTP54 - Feb 2, 2017 Easily animate your custom controls with mutimedia timer Using the given code any control(or form) can be invalidated every millisecond (yes every 1ms not 15.6ms), so that you could animate it easily. First add the following to your project: Link to code How to implement Suppose I have a control called c1 (or a thembase): PHP Code To use the code, just add the line Implements AnimatedObject Some errors pop up at the word 'AnimatedObject'. Just ignore them and paste this: PHP Code The above was done so that our ticker function can invalidate controls of all type since AnimatedObject is an interface, it doesn't matter what base control you've inherited. For people who use a themebase, just do the above in the themebase else you have to add it to your control(another reason to use themebase). How to use In the constructor, add PHP Code Similarly, in destructor ( dispose() func. ), add: PHP Code Now, when you set the animating property of your control to true, your control starts invalidating every 1ms. You can put your animation code like calculating values in the top of your onpaint() override to do it every 1ms. To stop, just set animating=false. Some would say why not just use a timer, for them:
About the leavemouse() sub The leavemouse sub can be used to trigger the onmouseleave() event of a control whenever the mouse passes over another control/form. All of the above can be added to your themebase Credits:
* - SIM-1847363 - Feb 3, 2017 I still have to look over this, overall doesn't look bad, in my case I would have used threading. |