News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Update, clipping, invalid

Started by bf2, October 17, 2012, 01:35:11 AM

Previous topic - Next topic

bf2

What is the difference or relationship between:
- Update region
- Clipping rectangle
- Invalid rectangle.

I see these terms being used in both Petzold and Iczellion but without a precise definition.

Could someone define them and their relationships in plain English please?

Thanks.

TouEnMasm


in "plain english" you have it on msdn with many details,update,samples ....
just type for example "msdn GetUpdateRgn"
Fa is a musical note to play with CL

bf2

I have tried MSDN - ended up more confused unfortunately.

For example I cannot tell from MSDN if update region and invalid rectangle are the same.

dedndave

Quote from: bf2 on October 17, 2012, 01:58:51 AM
I have tried MSDN - ended up more confused unfortunately.

i hear ya - lol
there is a lot of material to cover when it comes to painting and drawing
read it - read it again - and again - and again   :P
play with it along the way

the update region is a collection of invalidated regions
the OS keeps track of the update region
you can invalidate a region or a rectangle (usually the latter)
doing so causes the OS to "add that region to the pile", so to speak
when a WM_PAINT message is sent to a window, the collective total rectangle is sent via PAINTSTRUCT
the BeginPaint/EndPaint sequence clears the collective update region
notice that the update region can include things like windows moving on top of each other, as well as you drawing
you can also validate regions or rectangles to remove them from the pile

a clipping rectangle is a more general term that is used in many ways
for example, if i draw text that extends beyond the window boundry, it is clipped
or - if i have 2 child windows that overlap each other, one of them may be clipped

it can help reduce CPU usage if you only update the rectangle specified in PAINTSTRUCT
for beginners, it is convenient to ignore this and just update the entire window
it makes the code easier to write
but, once you have the hang of it, you will want to add code that limits the update to PAINTSTRUCT.rcPaint