procedure Sqlchangthread.execute;
begin
FreeOnTerminate := True;
Dbgrideh1.Canvas.lock; //去掉这句就会经常出现 Canvas does not allow drawing 错误
//但是一加上去就会无响应假死
with ADOQuery1 do
begin
Close;
DisableControls;
Prepared:=true;
SQL.clear;
sql.Add('select * from tablename ');
open;
EnableControls;
end;
Dbgrideh1.Canvas.Unlock;
end;
begin
FreeOnTerminate := True;
Dbgrideh1.Canvas.lock; //去掉这句就会经常出现 Canvas does not allow drawing 错误
//但是一加上去就会无响应假死
with ADOQuery1 do
begin
Close;
DisableControls;
Prepared:=true;
SQL.clear;
sql.Add('select * from tablename ');
open;
EnableControls;
end;
Dbgrideh1.Canvas.Unlock;
end;
What does the error message 'Canvas does not allow drawing ' mean? A:
you may have run out of resources, which means a new DC cannot be
allocated. Usually this is a result of not freeing unused DCs or other
objects you are attempting to draw to an device context that is not yet valid.
Such as in the create constructor of a component. you are trying to draw on a canvas while your last draw-operation has
not finished yet. In this case you can use Canvas.Lock or Canvas.TryLock to fix it.