CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    22

    basic graphic programming mfc app

    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?

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: basic graphic programming mfc app

    Quote Originally Posted by martijnberntsen
    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?

  3. #3
    Join Date
    Oct 2005
    Posts
    22

    Re: basic graphic programming mfc app

    I now do
    Code:
    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?
    Last edited by martijnberntsen; October 10th, 2005 at 04:50 PM.

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: basic graphic programming mfc app

    Quote Originally Posted by martijnberntsen
    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.

    Quote Originally Posted by martijnberntsen
    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.

  5. #5

    Re: basic graphic programming mfc app

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured