Click to See Complete Forum and Search --> : basic graphic programming mfc app
martijnberntsen
October 9th, 2005, 06:22 AM
I'm building a program (who doesn't..) and I paint in the OnPaint event the following to the screen:
http://www.aavrs.nl/pda/valueadj.JPG
this is repainted every mousemove, and this looks bad, very flickery.
is there a more efficient of better way to paint this to the window of my application?
gstercken
October 10th, 2005, 04:36 PM
I'm building a program (who doesn't..) and I paint in the OnPaint event the following to the screen:
this is repainted every mousemove, and this looks bad, very flickery.
is there a more efficient of better way to paint this to the window of my application?Well, how are you triggering the repainting? Are you drwing from within your mouse move handler, or are you just invalidating the relevant parts of your window's client ares?
martijnberntsen
October 10th, 2005, 04:46 PM
I now do
Invalidate();
UpdateWindow();
could I somehow invalidate part of the window? ( changes take place only at 2 rectangles of 10x10 pixels)
update: I now do Invalidate(false), that's much smoother now, any more improvements I can make?
gstercken
October 10th, 2005, 04:56 PM
could I somehow invalidate part of the window? ( changes take place only at 2 rectangles of 10x10 pixels)Yes, take a look at InvalidateRect() and InvalidateRgn(), you would normally use one of those instead of always invalidating the entire client area. Also note that UpdateWindow() is not necessarily required.
update: I now do Invalidate(false), that's much smoother now, any more improvements I can make?Well, that just avoids erasing the background. Be aware however that it might not always be what you need. For example, where are you painting your blue background? In reaction to WM_PAINT or to WM_ERASEBKGND?
In addition to all that, you get the smoothest and most flicker-free redrawing by using an offscreen bitmap. However, it's overkill for most cases, so you should try the regular approaches (invalidating only required parts, correctly separating background- and foregreound painting) first.
andytim
October 12th, 2005, 02:50 AM
For simple ficker free,you can find tons of articles on codeguru or codeproject,I think most of them should help you solve your problems,you can also consider to use other third flow/diagram kit to do it also,it contains professional look,such as XD++ MFC Library,you can find it with:
http://www.********.net/XDFeature/feature37.htm
Hope it is useful to you.
Andy
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.