procedure LockControl(c: TWinControl; bLock: Boolean);
begin
if (c = nil) or (c.Handle = 0) then Exit;
if bLock then
SendMessage(c.Handle, WM_SETREDRAW, 0, 0)
else
begin
SendMessage(c.Handle, WM_SETREDRAW, 1, 0);
RedrawWindow(c.Handle, nil, 0,
RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
LockControl(DBGrid1, True);
try
// do convoluted things to the grid
finally
LockControl(DBGrid1, False);
end;
end;
|