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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops (cut and past is not always very good)
Memo1.Lines.BeginUpdate;
try
.. code adding lines ..
finally
Memo1.Lines.EndUpdate;
end;
Memo1.Lines.BeginUpdate;
try
.. code adding lines ..
finally
Memo1.Lines.EndUpdate;
end;
LockWindowUpdate(Memo1.Han dle);
// do your stuff
// ..
LockWindowUpdate(0);
Regards,
Steve
// 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;
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.
Ok, the System detect this state by every call to functions like Invalidate() or RedrawWindow() and avoid now some addtional code.
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