DelphiFAQ Home Search:

Msg 'Canvas does not allow drawing'


comments17 comments. Current rating: 4 stars (4 votes). Leave comments and/ or rate it.


What does the error message 'Canvas does not allow drawing' mean?


  1. 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.
  2. you are attempting to draw to an device context that is not yet valid. Such as in the create constructor of a component.
  3. 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.


You are on page 1 of 2, other pages: [1] 2
2007-02-26, 19:01:05 from New Zealand  
This issue happened to me when I was trying to use ShowMessage inside a thread's Execute method. It didn't happen when I stepped through the code, only when running it without breakpoints. Odd. I guess the ShowMessage function is not thread safe, or something.
2007-03-21, 09:36:02
anonymous from Brazil  
The problem is on GetAveCharSize function, you need to change line 128 of dialogs.pas from
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
If IsMultiThread Then
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
If IsMultiThread Then

After this change, showmessage, inputbox and messagedlg become 'BeginThread' friendly... (Since BeginThread sets IsMultiThread to true...)
I do some test into running activescript in a thread, and get this canvas errors often with all boxes from dialogs, i test with my own copy of dialogs (called messageboxes) and the errors still occurred.
After this change, i test and do not see the canvas errors again. (yes, I DIG deeply into VCL to find... lol... 'CreateHandle' of TControlCanvas try to 'free' some handles when the internal list becomes full... if can 'lock' it... sometimes... he free ITSELF... causing null handle and this errors... only on multithread applications... off course...
2007-04-11, 02:36:11
[hidden] from Netherlands  
At my system this occered when ASUS probe was running. After deleting ASUS probe no problems anymore.
2007-06-24, 17:06:36   (updated: 2007-06-24, 17:07:42) from Netherlands  
Hi, today I purchased Digital Picture Recovery to recover digital picture that have been lost o my computer. After scanning my hard-drive you have to select which picture you want to recover, but then disaster strikes: I get the message: Canvas doe not allow drawing.
Dos anyone knows what the problem is and what can be done about it??
2007-07-04, 03:22:52
[hidden] from United Kingdom  
i am trying to run few things in my thread which initiate a form object , so i am getting the error in the Create line of my code.
I could not figure out where to place the TryLock/Lock . so can you help me in this regard.
2008-02-08, 04:38:29   (updated: 2008-02-08, 04:39:56)
ageu from Brasķlia, Brazil  

Ativar a propriedade

panel: TPanel

panel.DoubleBuffered := True;
2008-02-18, 19:44:18
anonymous from United States  
I found that if you turn off Asus Prob, the Msg 'Canvas does not allow drawing' will stop.
2008-05-07, 10:47:37
anonymous from Brazil  
amigos tem um programa que da esse erro canvas does not allon drawing, so que no windows 98 ele roda normal quando passo para o windows xp, e que da esse erro, como faƧo para corrigi esse erro.
2008-09-07, 06:47:20
sMallcar from Taiwan  
I just fix My problem with 'Canvas does not allow',

that's because I draw the canvas in event Timer,

I just add Canvas.lock at the Timer begin
and Canvas.unlokc at the Timer end.

like this
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
if not DXDraw1.CanDraw then exit;


it's works. Hope this message CAN HELP some guys who got the same problem with me
2009-09-10, 09:14:29   (updated: 2009-09-10, 09:15:12)
To fix it I used this workaround:

While (comp.Canvas.LockCount = 1) do

.. my operations ...
2010-01-12, 09:42:35
anonymous from United States  
i get this message when testing a product of my company's (MFact's NAV Dashboard) and I get this a lot more often on my vista pc compared to my xp pc. Should our code be changed to effect vista compared to xp? is there something i can suggest so it works in both environments?
Any help and suggestions in advance are greatly appreciated. Thank you!
2010-01-13, 05:38:15
2010-05-05, 10:28:04   (updated: 2010-05-05, 10:33:17)
Anderson PETERLE from Brazil  
Hi, I have 'fixed' this problem setting a virtual printer on system, some like 'Microsoft XPS Document Writer'.
Now, I'm begining a implementation of a routine on my application to makes a search for a real configured printer and display a alert message on case of inexisting that.

Em PortuguĆŖs BR: Eu contornei o problema apĆ³s configurar como padrĆ£o uma impressora virtual, como a oferecida pelo MS-Windows. Agora iniciarei a implementaĆ§Ć£o de uma rotina em minha aplicaĆ§Ć£o para verificar pela existĆŖncia de uma impressora configurada no sistema e alertar em caso negativo.


2012-03-23, 03:06:38
anonymous from Taiwan  
I had resulted it.
1. You can try to put the problem procedure in vc dll project.
2. keep the main form call dll function.
You are on page 1 of 2, other pages: [1] 2



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: