Jump to content


Win32 Screen Updating...


  • You cannot reply to this topic
4 replies to this topic

#1 netwalker

    Member

  • Members
  • PipPip
  • 72 posts

Posted 13 November 2007 - 12:43 PM

Hi All,

Right I'm having trouble optimizing a draw routine within the client area of an application that I'm writing (using the Win32 API). The problem is that I'm getting excessive updates when I resize the client area of my application. This results in some terrible screen flashing that is quite disconcerting. Basically what I want to do is update the client drawing area when the client area is bigger than its previous size. I only want the portion of the client area that is revealed drawn and nothing else. I can detect when the client area is smaller and thus no update occurs, however the flashing occurs when the client area gets larger. I know about functions InvalidateRect() and ValidateRect() as these functions add and remove rectangles. However I'm not sure how to use these in the context of my situation.

Any advices much appreciated,

netwalker.

#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 13 November 2007 - 01:27 PM

Are you using a NULL background brush (or implementing a dummy WM_ERASEBKGND)? Otherwise, when calling BeginPaint(), the WM_ERASEBKGND message will be sent and the default window handler (DefWindowProc) will start clearing the entire client area using the window background brush.

(And make sure your window class style doesn't include CS_HREDRAW and CS_VREDRAW)
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#3 netwalker

    Member

  • Members
  • PipPip
  • 72 posts

Posted 13 November 2007 - 01:43 PM

.oisyn said:

Are you using a NULL background brush (or implementing a dummy WM_ERASEBKGND)?
Yes, I'm now using a null brush and this has completely removed the flashing. Does this now mean that'll have to update the client background manually?. Can I do this through the WM_ERASEBKGND message or will I need to process some additional message(s)?.

.oisyn said:

(And make sure your window class style doesn't include CS_HREDRAW and CS_VREDRAW)
Do these attributes matter now that I'm using a NULL brush?. Could you suggest others that I can look at?.

Many Thanks.

#4 netwalker

    Member

  • Members
  • PipPip
  • 72 posts

Posted 13 November 2007 - 01:52 PM

Sorry there .oisyn I've just had look at the style bits documentation for the window class and now understand why the excessive drawing was happening and how to remove it. Now my application is working as I expect it too.

netwalker.

#5 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 13 November 2007 - 01:57 PM

netwalker said:

Yes, I'm now using a null brush and this has completely removed the flashing. Does this now mean that'll have to update the client background manually?
Well, yes, but aren't you doing that already when drawing? Btw, for more complicated drawing tasks I recommend drawing to an offscreen HDC first and then do a BitBlt() to your window. This will avoid all kinds of flashing when drawing things on top of other things.

Quote

Can I do this through the WM_ERASEBKGND message or will I need to process some additional message(s)?.
You can listen to the WM_ERASEBKGND message if you want and provide your own background clearing routine, but you can do it just as easily in the WM_PAINT. The PAINTSTRUCT that is filled by BeginPaint() has a fErase flag, that represents whether the background of the invalidated area should be redrawn.

Quote

Do these attributes matter now that I'm using a NULL brush?. Could you suggest others that I can look at?.
Yes. Basically, with these styles on your window class, a resize will not only invalidate the part that becomes visible but the entire client area (so also when you are shrinking the window!). Without the styles only the parts that matter will get drawn (as in, a correct clip region is set on the DC when calling BeginPaint())
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users