Solved

canvas error

Posted on 2001-09-11
6
338 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: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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

17 Experts available now in Live!

Get 1:1 Help Now