views:

76

answers:

2

I have created a simple paint application in VC# 2008 with the help of a YouTube video. Its code is as here:

http://paste.pocoo.org/show/268704/

The problem with the code is that if I draw something in the picturebox, minimize the application, and thn maximize it, whatever I had drawn, disappears. The picturebox becomes clear. Why is it so? Plz help me.

+1  A: 

You should be doing your painting during the Paint event. This event completely redraws the image. So when you un-minimize the application, the image is redrawn and you don't do anything.

Your application needs to store information about what has been drawn so that it can be redrawn. This is an example of the Model-View-Controller model. The PictureBox is the viewer, the stored information is the model and mouse event listeners will be part of the controller that can make alterations to the model.

unholysampler
A: 

See this link, and the rest of the site too:

http://bobpowell.net/picturebox.htm

Chris Dunaway