Board index » delphi » Help, 'Canvas does not allow drawing'

Help, 'Canvas does not allow drawing'

   Hello, folks.

   Recently, I wrote a program to show a user interface. this

program output to the Canvas of a special TImage object. And it

will redraw to the canvas when I press a special key.

   But I think it has a serious problem. That is, When I press

the key continually. Delphi will occur a error box "Canvas does

not allow drawing" sometime and somewhere, and then it will shut

down my computer. At last, It will not get normal until I restart

my computer.

   This problem has disturbed me for a long time. and I really

don't know too much about it.

   So, anyone who can tell me, Why the error message will appear?

and what happened? How to solve?

   Urge for your answer, Thank you.

additional:

   Just now, I find out the point of this problem is:

   I set a clip rectangle using following procedure. when I

disenable it, the problem go away. So who can tell me how to

set a clip rectangle safely. Please help me. Thank you very

much.

******************************************************************
procedure SetClipRect(Canvas:TCanvas;r:TRect);
var
   hr : HRGN;
begin
   hr := CreateRectRgn(r.Left, r.Top, r.Right+1, r.Bottom+1);
   SelectObject(Canvas.Handle,hr);
//   ExtSelectClipRgn(Canvas.Handle,hr,RGN_COPY);
end;
*******************************************************************

 

Re:Help, 'Canvas does not allow drawing'


You are running out of resources.  I think that after using your region, you
need to call DeleteObject.
________________________________________

Glenn Benes
InfoComp International, Inc.

Quote
dys wrote in message <7ifmvc$r...@forums.borland.com>...
>******************************************************************
>procedure SetClipRect(Canvas:TCanvas;r:TRect);
>var
>   hr : HRGN;
>begin
>   hr := CreateRectRgn(r.Left, r.Top, r.Right+1, r.Bottom+1);
>   SelectObject(Canvas.Handle,hr);
>//   ExtSelectClipRgn(Canvas.Handle,hr,RGN_COPY);
>end;
>*******************************************************************

Other Threads