Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 51245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:43:13+00:00 2026-05-10T16:43:13+00:00

I need to knock out a quick animation in C#/Windows Forms for a Halloween

  • 0

I need to knock out a quick animation in C#/Windows Forms for a Halloween display. Just some 2D shapes moving about on a solid background. Since this is just a quick one-off project I really don’t want to install and learn an entire new set of tools for this. (DirectX dev kits, Silverlight, Flash, etc..) I also have to install this on multiple computers so anything beyond the basic .Net framework (2.0) would be a pain in the arse.

For tools I’ve got VS2k8, 25 years of development experience, a wheelbarrow, holocaust cloak, and about 2 days to knock this out. I haven’t done animation since using assembler on my Atari 130XE (hooray for page flipping and player/missile graphics!)

Advice? Here’s some of the things I’d like to know:

  • I can draw on any empty widget (like a panel) by fiddling with it’s OnPaint handler, right? That’s how I’d draw a custom widget. Is there a better technique than this?
  • Is there a page-flipping technique for this kind of thing in Windows Forms? I’m not looking for a high frame rate, just as little flicker/drawing as necessary.

Thanks.

Post Mortem Edit … ‘a couple of coding days later’

Well, the project is done. The links below came in handy although a couple of them were 404. (I wish SO would allow more than one reply to be marked ‘correct’). The biggest problem I had to overcome was flickering, and a persistent bug when I tried to draw on the form directly.

  • Using the OnPaint event for the Form: bad idea. I never got that to work; lots of mysterious errors (stack overflows, or ArgumentNullExceptions). I wound up using a panel sized to fill the form and that worked fine.
  • Using the OnPaint method is slow anyway. Somewhere online I read that building the PaintEventArgs was slow, and they weren’t kidding. Lots of flickering went away when I abandoned this. Skip the OnPaint/Invalidate() and just paint it yourself.
  • Setting all of the ‘double buffering’ options on the form still left some flicker that had to be fixed. (And I found conflicting docs that said ‘set them on the control’ and ‘set them on the form’. Well controls don’t have a .SetStyle() method.) I haven’t tested without them, so they might be doing something (this is the form):

        this.SetStyle(ControlStyles.UserPaint, true);     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); 

So the workhorse of the code wound up looking like (pf is the panel control):

    void PaintPlayField()     {         Bitmap bufl = new Bitmap(pf.Width, pf.Height);         using (Graphics g = Graphics.FromImage(bufl))         {             g.FillRectangle(Brushes.Black, new Rectangle(0, 0, pf.Width, pf.Height));             DrawItems(g);             DrawMoreItems(g);             pf.CreateGraphics().DrawImageUnscaled(bufl, 0, 0);         }     } 

And I just called PaintPlayField from the inside of my Timer loop. No flicker at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:43:13+00:00Added an answer on May 10, 2026 at 4:43 pm

    Set off a timer at your desired frame rate. At each timer firing twiddle the internal representation of the shapes on the screen (your model) per the animation motion you want to achieve, then call Invalidate(true). Inside the OnPaint just draw the model on the screen.

    Oh yeah, and you probably want to turn Double Buffering on (this is like automatic page flipping).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

need ask you about some help. I have web app running in Net 2.0.
I need to knock up a very quick prototype/proof of concept application to demo
Need some pointers to resources for learning about Image processing used in Augmented Reality.
I need to know about Epoll On linux System. Could you recommend manual or
Need help in figuring out a way to fetch a particular block of content
need advice about the following with the following ksh script I actually copy file1
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.
Need to an expression that returns only things with an I followed by either
Need to locate the following pattern: The letter I followed by a space then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.