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
kim_rayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.