uses Windows,ComCtrls,Messages
var FUpdatingCounter : Integer;
FOldEventMask : LongInt;
procedure BeginUpdate(RE:TRichedit);
begin
inc(FUpdatingCounter);
// handle nested calls
if FUpdatingCounter=1
then begin // lock
FOldEventMask:=SendMessage(RE.Handle,EM_SETEVENTMASK,0,0);
// raising events and
SendMessage(RE.Handle,WM_SETREDRAW,0,0)
// redrawing itself
end
end;
procedure EndUpdate(RE:TRichedit);
begin
dec(FUpdatingCounter);
// handle nested calls
if FUpdatingCounter=0
then begin // unlock
SendMessage(RE.Handle,WM_SETREDRAW,1,0);
// redrawing itself
SendMessage(RE.Handle,EM_SETEVENTMASK,0,FOldEventMask )
// and raising events
end
end;