Solved

canvas error

Posted on 2001-09-11
6
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
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
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!

 
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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