Solved

canvas error

Posted on 2001-09-11
6
337 Views
Last Modified: 2010-04-06
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
Comment
Question by:el_shiro
6 Comments
 
LVL 22

Expert Comment

by:mnasman
ID: 6473617
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
 

Expert Comment

by:rrivas
ID: 6475237
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
 
LVL 9

Expert Comment

by:ITugay
ID: 6476578
Hi el_shiro,

try use this construction, sometimes it helps.

  if HandleAllocated then
  begin
    // perform drawing here
  end;

-----
Igor.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Expert Comment

by:cubud
ID: 6476639
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
 
LVL 6

Expert Comment

by:edey
ID: 6494426
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8280646
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now