Jump to content
  • Advertisement
Sign in to follow this  
danny_dev

gdi+ question

This topic is 4554 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

Hello, I'm new to graphics programming, starting with gdi+ and c#. I'm trying out a few tutorials and although i do progress quite a bit, i have a problem in understanding the sequence of things. Programming in C#, all tutorials say that you get the Graphics object on the onpaint / paint event where it comes to you as an argument. my question is, i wanna do graphics from other places in the program so i tried to copy the Graphics object (the one that comes as argument to the paint event) to a member variable so that i can use it from other places in the app, but it doesnt seem to work. Which makes me wonder for instance, if i wanna get the mouse-clic event, to do something with the graphics already on the form (a loaded bitmap for example) how am i going to do that? if i do CreateGraphics(...) in the mouse click event it doesnt work. it all gets overriden by the graphics object that comes to the OnPaint! I probably got wrong some basic design issues here... Any help would be apreciated. Danny

Share this post


Link to post
Share on other sites
Advertisement
If you want to do something like that, I suggest calling the form's repaint() method in your mouse-click event handler. The repaint() method will call the form's paint() method. You will want to work with the Graphics object passed to the paint() method since its the one that can manipulate the Form.

Share this post


Link to post
Share on other sites
hello, thank you for your reply.

Iwas hoping there was a better solution to this...

so, if we assume that i make something that when the mouse is clicked it should draw a small circle at the point on the bitmap where the click occured, how am i supposed to do that? Should i put a member variable for the 'action', set the variable in the onclick event and then call repaint where it should have a switch for all the actions, select the correct one and do it?

Am I suppose to write all the logic for the app in the paint event of the form? or am i still missing something here???

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!