• Advertisement
Sign in to follow this  

BeginPaint

This topic is 4729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a little tourble understaning the BeginPaint process. So I got a couple questions:
Quote:
from msdn.com The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, BeginPaint sends a WM_ERASEBKGND message to the window. An application should not call BeginPaint except in response to a WM_PAINT message. Each call to BeginPaint must have a corresponding call to the EndPaint function. If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased. If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region before returning.
clear up a few things for me, to be on the safe side: First question: Say I called InvalidateRect with the last parameter set to FALSE, will BeginPaint still send out a WM_ERASEBKGND message? If it does not, then, BeginPaint never erases the background before returning right?
Quote:
If the update region is marked for erasing, BeginPaint sends a WM_ERASEBKGND message to the window.
Secon Question: I know that calling InvalidateRect with the last paramter set to TRUE marks the invalid area for erasing later (during BeginPaint), but, say I don't use InvalidateRect to produce a WM_PAINT message and I get the message the normal way (resize/move/uncover the window etc..), does the invalid region still get "marked" automatically by windows for erasing or what? Third question: How many WM_ messages in total does BeginPaint actually send out or could send out and in what order? I know it could send out WM_ERASEBKGND and WM_NCPAINT, any others? Forth question: I decide to process the WM_ERASEBKGND message and return 1;, does this cause the fErase field of the PAINTSTRUCT structure to be set to 0? And last but not least: during the ShowWindow process (with 2nd parameter set to SW_SHOWNORMAL), The windows client area is yet to be drawn/erased to so it's invalid right? does that mean ShowWindow sends out a WM_PAINT message? If it does'nt, then isn't this contradicting what msdn says: The presence of an invalid region causes a WM_PAINT message to be sent to the window procedure. I feel stupid asking these questions but I just don't get how these functions work exactly and in what order the messages are sent out first so I can make logical decisions as to what to do next.

Share this post


Link to post
Share on other sites
Advertisement
1. If InvalidateRect() has FALSE as the third parameter then WM_ERASEBKGND is not sent and so the background is never erased. This is used if you know that you are going to paint over the entire background so erasing it would just be pointless.

2. I'm not sure about this. I think the answer is probably yes but you could always test it by handling WM_ERASEBKGND in such a way that it would log when it is called.

3. If any, you probably dont care about them (like WM_SYNCPAINT)

4. Yes, I believe fErase will be changed to FALSE

5. The window's client area will be invalid so a WM_PAINT message should be in the message queue.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement