Paint on lostfocus

  • Thread starter Thread starter Tamir Khason
  • Start date Start date
T

Tamir Khason

Why when I lost focus (go to back) on form all GDI+ paints disappears.....
BUG or I do something wrong????

TNX
 
OK figured what is the problem:
while lost focus on form occures event of Paint (I draw there) - Is any way
to prevent it??? or maybe other event to paint on load (_load do not work...
it's paits controls afterware...) ???
 
You are most likely painting stuff outside of OnPaint.

OnPaint needs to know how to draw everything, since the window don't
remember how it looks, it just appears to, until something covers part of
it or all.
 
I'm sorry, I'm a little confused. What are you trying to do?
When focus is given, the paint event is thrown to notify your program that
it needs to redraw it's own window.
You don't want to prevent the OnPaint event.
 
Hi Tamir,

I do not think you want to prevent the paint event to happen.
The paint event occurs whenever some area of your form is invalid. If you
stopped paint event, the invalid area will not draw back, while it may
remain its being overlapped graphic.(For example, when you place a window
over your form, then move the window away, your form will not repaint, so
it being overlapped area will still remain the winodw's graphic. )

The right solution is store your paint DC and whenever the paint event
happens, redraw your invalid area. But most of these things have been done
by the windows, so you only need to focurs some few things. For example, if
you update some UI elements of WinForm, most of the time .Net Framework
will invoke the paint event(through invoke Invalidate method to achieve
this) for you, but some times, you need to explicit invoke the Invalidate
method to notify your form to repaint.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top