Board index » delphi » Is LockWindowUpdate the right thing

Is LockWindowUpdate the right thing

I need to move and to hide/unhide some controls during Runtime. In order to
make this fast an to hide the drawing process i did the following:

LockWindowUpdate(MainForm.WindowHandle);
DoTheGraphicStuff;
MoveCustomControls;
HideAndUnhideControls;
LockWindowUpdate(0);

I lock the window during the movement of the controls. But everytime i do
this, a very short flicker occurs on the whole screen.
Is there a way to suppress this flicker or is there a better and faster way
the LockWindowUpdate.

Thank you

 

Re:Is LockWindowUpdate the right thing


Quote
In article <8v7c3n$m...@bornews.inprise.com>, Ulli Kindler wrote:
> I lock the window during the movement of the controls. But everytime i do
> this, a very short flicker occurs on the whole screen.

> Is there a way to suppress this flicker or is there a better and faster way
> the LockWindowUpdate.

Well, I had/have the same problem.
You can try to do a
SendMessage(Mainform.Handle,WM_SETREDRAW,0,0);
This causes all paint messages to be ignored. Turn them on with
SendMessage(Mainform.Handle,WM_SETREDRAW,1,0);
But it can look ugly if you don't time it right, I've given up on it and use
Locked:=LockWindowUpdate(Mainform.ClientHandle);
..
if Locked then
  LockWindowUpdate(0);
instead, following a suggestion by Peter Below, works better for me.  

Renate

Re:Is LockWindowUpdate the right thing


Quote
>Well, I had/have the same problem.
>You can try to do a
>SendMessage(Mainform.Handle,WM_SETREDRAW,0,0);
>This causes all paint messages to be ignored. Turn them on with
>SendMessage(Mainform.Handle,WM_SETREDRAW,1,0);
>But it can look ugly if you don't time it right, I've given up on it and
use
>Locked:=LockWindowUpdate(Mainform.ClientHandle);
>...
>if Locked then
>  LockWindowUpdate(0);

Thank you. You are right, it is almost impossible to find the right timing
with SendMessage (Mainform.Handle,WM_SETREDRAW,0,0). But if I use LockWindowsUpdate
with MainForm.ClientHandle instead of MainForm.WindowHandle it does not work
in the same way. If I use ClientHandle i can still see to process of repainting
every single control (TCustomControl) and it isn't faster then without LockWindowUpdate.
Only LockWindowUpdate(MainForm.WindowHandle) hides the painting almost completely
- but only with this damn screen flickering.

Re:Is LockWindowUpdate the right thing


Quote
In article <8v865k$8...@bornews.inprise.com>, Ulli Kindler wrote:
> Only LockWindowUpdate(MainForm.WindowHandle) hides the painting almost completely
> - but only with this damn screen flickering.

Yes, my experience completely. Wish somebody had a better solution, but I haven't
found any, so far, and I've looked quite a bit. Hope I didn't spoil any of your
response chances, it's just that I'm interested.

Renate

Re:Is LockWindowUpdate the right thing


Hi Renate,

i finally found a solution that works very well here:

Application.ProcessMessages;
CreateBackgroundImage;
Resize MainForm;
SendMessage(MainForm.Handle,WM_SETREDRAW,0,0);
Move, Hide&Unide Controls (TCustomControl);
SendMessage(ProMixer.Handle,WM_SETREDRAW,1,0);
invalidateRect(ProMixer.WindowHandle,nil,false);
Control1.invalidate
Control2.invalidate
Contorl3.invalidate... and so on
Application.ProcessMessages;

I manual invalidate every control after the second WM_SETREDRAW message.
The screen does not flicker, it is as fast as LockWindowUpdate and it looks
even better.

Re:Is LockWindowUpdate the right thing


I use

LockWindowUpdate(GetDesktopWindow())
try
  do your stuff....
finally
  LockWindowUpdate(0)
end;

It works fine without the flicker of the icons in the desktop

Regards
Harald

"Ulli Kindler" <ukind...@htwm.de> schrieb im Newsbeitrag
news:8v7c3n$mcg1@bornews.inprise.com...

Quote

> I need to move and to hide/unhide some controls during Runtime. In order
to
> make this fast an to hide the drawing process i did the following:

> LockWindowUpdate(MainForm.WindowHandle);
> DoTheGraphicStuff;
> MoveCustomControls;
> HideAndUnhideControls;
> LockWindowUpdate(0);

> I lock the window during the movement of the controls. But everytime i do
> this, a very short flicker occurs on the whole screen.

> Is there a way to suppress this flicker or is there a better and faster
way
> the LockWindowUpdate.

> Thank you

Re:Is LockWindowUpdate the right thing


Quote
In article <8v8chf$4...@bornews.inprise.com>, Ulli Kindler wrote:
> i finally found a solution that works very well here:

Hi Ulli,

it almost works for me, but I've got a bunch of images and memos in a
scrollbox, and I can't get the scrollbar repainted properly. I've
switched over to Harald's solution, best I've tried so far. Only Gotcha
I can see is, a user having another application running on the desktop
which updates itself regularly, might be surprised. But I can live with
that :)

Renate

Re:Is LockWindowUpdate the right thing


Hello

I always use following function and it works fine when you use the right
control (panel or tabsheet). I also use a Sendmessage but when unlocking I
use the API call RedrawWindow.

procedure LockControlPaint(Cntrl : TWincontrol; BlnLockStatus : boolean);
begin
  if (Cntrl =nil) or (Cntrl .handle=0) then
    Exit;

  if BlnLockStatus then
    SendMessage(Cntrl .Handle,WM_SETREDRAW,0,0)
  else
  begin
    SendMessage(Cntrl .Handle,WM_SETREDRAW,1,0);
    RedrawWindow(Cntrl .Handle,nil,0,RDW_ERASE or RDW_FRAME or
RDW_INVALIDATE or RDW_ALLCHILDREN);
  end;
end;

Best regards

Stefan Cruysberghs
http://bewoner.antwerpen.be/stefancr

"Renate Schaaf" <rena...@xmission.com> schreef in bericht
news:VA.00000281.04197ce8@xmission.com...

Quote

> In article <8v8chf$4...@bornews.inprise.com>, Ulli Kindler wrote:
> > i finally found a solution that works very well here:

> Hi Ulli,

> it almost works for me, but I've got a bunch of images and memos in a
> scrollbox, and I can't get the scrollbar repainted properly. I've
> switched over to Harald's solution, best I've tried so far. Only Gotcha
> I can see is, a user having another application running on the desktop
> which updates itself regularly, might be surprised. But I can live with
> that :)

> Renate

Other Threads