• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

error msg with toolbar : Canvas does not allow drawing

Hi all.

I have build a ie toolbar application. In my application i m feching rss feed and trying show it on my toolbar.Each tab have it's separate rss feed. I am handle all exception but when i swapping the tab some time then it's showing a error msg "canvas does not allow drawing".Each processing is in separate thread.

anyone has any suggestion and solutions.

thanx
0
kim_ray
Asked:
kim_ray
  • 3
  • 2
1 Solution
 
BdLmCommented:
what Delphi version did you use ?

Did you get an access voilation ?
0
 
kim_rayAuthor Commented:
i have delphi 7 and didn't get  access voilation ?
0
 
BdLmCommented:
using threats I assume 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.
0
 
kim_rayAuthor Commented:
no it's not handle

this is my function :

procedure TBandForm.showTimer(Sender: TObject);
var
 X:integer;
 begin
 lblticker.Caption:='';
 if currline>=txtticker.Lines.Count then  begin
 currline:=0;
 end;
 StyleTicker;

 X := (lblticker.Width div 2) - (Canvas.TextWidth(txtticker.Lines[currline]) div 2);
 x:=25;
  lblticker.Canvas.Lock;
 if tickermode='aaa' then begin

  lblticker.Canvas.Draw(7,2,MyImage.Picture.Graphic);
  lblticker.Canvas.TextOut(10+MyImage.Picture.Width,5,txtticker.Lines[currline]);
//  Canvas.Unlock;
end;
 if tickermode='bbb' then begin
  Canvas.Lock;
  lblticker.Canvas.Draw(7,2,MyImage.Picture.Graphic);
  lblticker.Canvas.TextOut(10+MyImage.Picture.Width,5,txtticker.Lines[currline]);
//  Canvas.Unlock;
end  else begin
  Canvas.Lock;
  lblticker.Canvas.Draw(7,2,MyImage.Picture.Graphic);
  lblticker.Canvas.TextOut(10+MyImage.Picture.Width,5,txtticker.Lines[currline]);
//  Canvas.Unlock;
end;
  lblticker.Canvas.Unlock;
  currline:=currline+1;
end;


0
 
BdLmCommented:
these are the main reasons for your failures:
... 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

Did the lock()I  unlock()  function change the failure?

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now