Link to home
Start Free TrialLog in
Avatar of omavideniz
omavideniz

asked on

Disable window update

hi,
is it possible to disable update of a control? it is a very slow process to insert lines to a tmemo control while the visual update in effect.
thanks
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi all,

I agree with meikl. I just wanted to say thay I always put the BeginUpdate/EndUpdate in a try/finally structure:

Memo1.Lines.BeginUpdate;
try
  .. code adding lines ..
finally
  Memo1.Lines.BeginUpdate;
end;

Regards Jacco
Oops (cut and past is not always very good)

Memo1.Lines.BeginUpdate;
try
 .. code adding lines ..
finally
 Memo1.Lines.EndUpdate;
end;
Avatar of SteveWaite
SteveWaite

 LockWindowUpdate(Memo1.Handle);
  // do your stuff
  // ..
  LockWindowUpdate(0);

Regards,
Steve
When I've needed something with a bit more strength, this is what is use:

with mywincontrol do
 begin
  Perform( WM_SETREDRAW, 0, 0 );
  try
    ...
  finally
    Perform( WM_SETREDRAW, 1, 0 );
    Invalidate;
  end;
 end;

All above methods don't speedup real, because the painting code is indeed executed, but with one exception. Any response to get a "visible" DeviceContext to the Screen retruns a invalid or virtual DC. This avoid that the following Paintingcode paints on the screen, but don't avoid this Paintingcode itself.
Ok, the System detect this state by every call to functions like Invalidate() or RedrawWindow() and avoid now some addtional code.