[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

canvas error

i've got a difficulty to detect an error "canvas doesn't allow drawing". can anybody help me why this error message appear? thanks.
0
el_shiro
Asked:
el_shiro
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
from http://www.delphifaq.com/fq/q4053.shtml


Msg 'Canvas does not allow drawing'
Q:
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.
0
 
rrivasCommented:
Maybe you don't have disk space or memory space or you have processes hangs up. Try to see you disk space.

Regards

RRivas
0
 
ITugayCommented:
Hi el_shiro,

try use this construction, sometimes it helps.

  if HandleAllocated then
  begin
    // perform drawing here
  end;

-----
Igor.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
cubudCommented:
Does the canvas belong to a TWinControl descendent or a TGraphicControl descendent ?

If TGraphicControl then you can only draw on the canvas during its OnPaint event.  In this case put your code in OnPaint and when you want to do the drawing do

MyControl.Invalidate;

Pete
http://www.HowToDoThings.com (Delphi articles)
http://www.Stuckindoors.com/delphi (Open source)
0
 
edeyCommented:
You may also get this if you're trying to draw to/use a HDC that isn't valid (yet) or if you attempt to treat a HWND like a HDC.  I'd go & check your code to make sure that you don't draw to or refrence any canvas of canvas handle in your cnostructors, or any other place untill your sure that all the initialization has been done.

GL
Mike
0
 
SpideyModCommented:
All,
I am unlocking this question in preparation for cleanup.  I will return in 7 days to finalize this question.  Please leave any recommendations for the final state of this question, I will take all recommendations into consideration.  Failing any feedback, I may decide in 7 days to delete or PAQ this question with no refund.  Thanks.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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