I reviewed that blog and continued to google LockWindowUpdate (LWU) and 
related API calls and sure enough on one of them that site has a much 
better explaination: Turns out that LWU can only be used by one window 
on the desktop. It is used for drag operations often and if there is a 
conflict one will not do as intended. This could affect  redrawing a 
window or not seeing a drag operation. Finally, when LWU is set back so 
redraw is possible, the entire desktop is redrawn.

The consensus for a better way is to use WM_SETREDRAW which only affects 
the window that is passed.

I settled on:

SendMessage(Form.handle, WM_SETREDRAW, 0,0) to Lock

and

SendMessage(Form.handle, WM_SETREDRAW, 1,0)
RedrawWindow( Form.handle, 0, RDW_FRAME + RDW_INVALIDATE +
RDW_ALLCHILDREN + RDW_NOINTERNALPAINT);  to UnLock/allow redraw

Using them together in a try...finally block. Works as expected for my 
use. BTW, a simple Repaint does not work to replace the RedrawWindow call.

Chuck Belanger

> I don't see anything in that blog to suggest it is not useful purposes other
> than drag operations.  One comment says...
>
> "We use LockWindowUpdate for avoiding extensive redraw operations when
> reorganizing child windows/controls in an window. Without it you can see the
> windows changing position, with it you don't and you just go from one layout
> to the new one without flickering."
>
> It sounds like the best method is to use DeferWindowPos but that looks much
> more difficult to use.
>
> Ross.
>   
>

_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to