此错误出现在
Refresh事件中已经有绘图代码
而再有窗体弹出对话框覆盖绘图区域(即需要被Redraw部分)
的情况下http://www.delphifaq.com/fq/q4053.shtml
此处有一些说明,但是
用了他所说的Lock或者TryLock的方法,在UnLock时程序挂起自己尝试使用全局变量的方法,在对话框弹出的前后,加以对Refresh事件的互斥限制
但也没有效果,到底如何解决?

解决方案 »

  1.   

    这是资源消耗太多,或者是取得的资源没有释放,一般就是HFONT,HBRUSH,HPEN等资源没释放
    还有一个原因就是CANVAS被锁定,没有解锁,一般用Canvas.Lock时,一定要这样写:
    Canvas.Lock;
    try
      执行的语句
    finally
      Canvas.Unlock;
    end;
      

  2.   

    你的REFRESH中把CANVAS给LOCK住了,所以弹出的窗口因为无法取得CANVAS进行重绘,所以出现此错误!修改你的REFRESH中引用CANVAS部分即应解决此问题!
      

  3.   

    Canvas does not allow drawing
      

  4.   

    那就加一个image,设置为对齐为clclient;image1.transparent:=true;然后在image上重画
      

  5.   

    在win98下这种情况很多,在win2k,winxp下情况会好一些,这是由于资源消耗太多,而且大量资源没有释放导致,请及时释放不用资源。image控件重叠极易发生该情况。
      

  6.   

    Question:What does the error message 'Canvas does not allow drawing' mean? Answer: 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. 
      

  7.   

    一般是 Canvas  没有Parent 控件时会有这个错误。