Original Post
I'm having a little tourble understaning the BeginPaint process. So I got a couple questions:
Quote: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?
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.
Quote: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.
If the update region is marked for erasing, BeginPaint sends a WM_ERASEBKGND message to the window.