Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Correct Way to Capture Form Resize/Paint in C#

This topic is 5353 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I need a bit of help here. I''ve got a very basic C# winforms application and I''m using the Graphics.DrawShape functions to draw directly on the form. I want what I''m drawing on the form to scale when the form is resized. I have all my drawing code in a function called DrawGraphics(). My problem is that I need to call DrawGraphics() whenever the form is repainted and whenever the form is resized. Trapping the Paint event isn''t enough, because making a form smaller doesn''t actually fire the event (I don''t know why not). However, often a resize event is followed by a paint event, so it turns out that in some cases I am calling DrawGraphics() twice when I really only need to do it once. I''ve had this problem in the past whenever I tried to scale GUI elements as the form was resized. So if someone could tell me how the pros handle this, that would be super. Thanks a lot! ---------------------------------------- Let be be finale of seem, seems to me. ---------------------------------------- Coding: http://www.stanford.edu/~jjshed/coding Miscellany: http://www.stanford.edu/~jjshed

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
When you make a window smaller, nothing *new* has to be drawn.
When you make it bigger, it does....

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!