Invalidate rectangle
-
I’m trying to display an animated bitmap in a win32 application with GDIplus. Last time when I talked about this here I was told I should invalidate a rectangle to force the App to refresh/draw another frame. I’m trying to understand the theory for now. I will come up with code in a day or two if necessary. My question is do you create and invalidate between beginpaint and endpaint a rectangle that has no particular purpose or does it have to be a rectangle that actually does something. I’m having a difficult time understanding the connection between a rectangle and the rendering process of a win32 api window
-
I’m trying to display an animated bitmap in a win32 application with GDIplus. Last time when I talked about this here I was told I should invalidate a rectangle to force the App to refresh/draw another frame. I’m trying to understand the theory for now. I will come up with code in a day or two if necessary. My question is do you create and invalidate between beginpaint and endpaint a rectangle that has no particular purpose or does it have to be a rectangle that actually does something. I’m having a difficult time understanding the connection between a rectangle and the rendering process of a win32 api window
Roughly speaking, the invalidated rectagle will be redrawn in the next
WM_PAINT
call (other parts of the client area are not redrawn). So, if you need to update a portion of the client area then invalidate the corresponding rectangle and then callUpdateWindow()
. In simple scenarios you can invalidate the entire client area and then callUpdateWindow()
. See, for instance: Invalidating the Client Area - Win32 apps | Microsoft Learn[^]."In testa che avete, Signor di Ceprano?" -- Rigoletto
-
Roughly speaking, the invalidated rectagle will be redrawn in the next
WM_PAINT
call (other parts of the client area are not redrawn). So, if you need to update a portion of the client area then invalidate the corresponding rectangle and then callUpdateWindow()
. In simple scenarios you can invalidate the entire client area and then callUpdateWindow()
. See, for instance: Invalidating the Client Area - Win32 apps | Microsoft Learn[^]."In testa che avete, Signor di Ceprano?" -- Rigoletto
Basically I need a rectangle taking the whole window for my game, I think I understand, I’ll post a followup if I’ll run into trouble setting things. Thank you.
-
Basically I need a rectangle taking the whole window for my game, I think I understand, I’ll post a followup if I’ll run into trouble setting things. Thank you.
-
I’m trying to display an animated bitmap in a win32 application with GDIplus. Last time when I talked about this here I was told I should invalidate a rectangle to force the App to refresh/draw another frame. I’m trying to understand the theory for now. I will come up with code in a day or two if necessary. My question is do you create and invalidate between beginpaint and endpaint a rectangle that has no particular purpose or does it have to be a rectangle that actually does something. I’m having a difficult time understanding the connection between a rectangle and the rendering process of a win32 api window
The only things you should be doing between
BeginPaint
andEndPaint
is redrawing/rewriting the parts of the client window that may have changed. Outside of theWM_PAINT
handler, you decide which part (or all) of the window needs to be repainted. You then set those values into a call toInvalidateRect
, which will post aWM_PAINT
message to your message queue. -
The only things you should be doing between
BeginPaint
andEndPaint
is redrawing/rewriting the parts of the client window that may have changed. Outside of theWM_PAINT
handler, you decide which part (or all) of the window needs to be repainted. You then set those values into a call toInvalidateRect
, which will post aWM_PAINT
message to your message queue.>The only things you should be doing between beginpaint and endpaint I was thinking to disregard everything that was rendered in one frame, and then render things all over again. Keeping track of pieces that visually change in my game ( if that’s what you mean) seems like a burden at this point. So far I’m only looking for a way to trigger a new paint event
-
>The only things you should be doing between beginpaint and endpaint I was thinking to disregard everything that was rendered in one frame, and then render things all over again. Keeping track of pieces that visually change in my game ( if that’s what you mean) seems like a burden at this point. So far I’m only looking for a way to trigger a new paint event
-
I see
-
I see
-
I’m trying to display an animated bitmap in a win32 application with GDIplus. Last time when I talked about this here I was told I should invalidate a rectangle to force the App to refresh/draw another frame. I’m trying to understand the theory for now. I will come up with code in a day or two if necessary. My question is do you create and invalidate between beginpaint and endpaint a rectangle that has no particular purpose or does it have to be a rectangle that actually does something. I’m having a difficult time understanding the connection between a rectangle and the rendering process of a win32 api window
I might do some searching through CP. There are some excellent articles covering the madness of Windows drawing, GDI, etc. DCs, their variations and purposes are also covered pretty well. Just keep in mind the point behind InvalidateRectangle - GDI is somewhat smart. It will limit it's drawing to regions it knows it needs to re-draw which is why you need an InvalidateRectangle call.
Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.