[Lazarus] Getting update rect/region in Windows

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon May 23 14:37:42 CEST 2011


Max Vlasov schrieb:

> I must admit I was wrong saying that ClipRect doesn't provide the 
> information about updating areas. It does, partly my misunderstanding 
> came from the naming change in Delphi. Usually win32 rect/region api 
> functions comes in pairs with similar names, but ClipRect property is 
> not a call to GetClipRect (there's no such function), but to GetClipBox 
> function that is just partly related to clipping regions. And Luiz is 
> also right referring to rcPaint member. So if one needs the update rect, 
> there are plenty of options already.

I've learned about Windows painting with Win 3.0, so my memory also may 
be a bit outdated now.


> Actually I needed access not only to update rect, but to the update 
> region (for example in order to effectively resolve small rectangles in 
> different areas of a big window). In this case I also found a 
> replacement for GetUpdateRgn, it's GetRandomRgn, documented not so long 
> ago (so I was not aware of its existence) and according to the help it 
> contains the correct region not only before, but also after BeginPaint. 
> So I will probably use this one instead of windowproc hacking

IMO the entire update region should be available for every window (by HWND).

> As for necessity for on-the-fly drawing, I usually pay much attention to 
> resources used and don't allocate much unless is necessary. The system 
> working on the fly consumes much less memory because doesn't use 
> intermediate buffer. Sometimes it even can not use bitmaps at all 
> (regions filling/framing) So there are several approaches, I think they 
> all have their rights to exist.

I've stopped optimizing (display) memory usage many years ago. At least 
Windows only keeps the actually required code and data in RAM (pages), 
so that memory usage is of interest only in very small (embedded, 
portable...) systems. When Windows nowadays keeps copies of the form 
bitmaps (ghosting), I see no more reason for replacing double-buffer by 
complicated code and on-the-fly painting.

DoDi





More information about the Lazarus mailing list