Onpaint question, restoring the background ??

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

I made a control that when pushed (mousedown) it draws a rectangle,
how can i restore the background when i release the button.

I think i need to capture the background before drawing my rectangle , end
restore it afterwards.

How can i do this in c# using the CF ?
 
The answer would depend on the way how the drawing is
implemented. If your drawing is happenning in the OnPaint
event that you should be able to fully control what's been
drawn or not. To force the control to re-paint you could
just make a call on Invalidate() method.
 
Hi Sagaert,

What is the background that you are drawing the rectangle on? You should
only need to capture it if you have done some other drawing that you cannot
recreate in OnPaint. If this is the case then I would suggest drawing to an
off-screen Bitmap object and then using it to update the control. This way
you can save the Bitmap before drawing the rectangle and restore the screen
with the saved Bitmap.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Would also need to be careful about the OnPaint event, as (I believe) it
does not fire properly when the controls parent is not the form (eg.
Label inside a panel, label OnPaint does not fire).
 
Back
Top