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

'Canvas does not allow drawing'

Can anyone throw any light on the above error message that comes up with one
of our custom components?

Thanks,

Tom

 

Re:'Canvas does not allow drawing'


"Canvas does not allow drawing" mean that the canvas you use has no valid
device context handle at the time you try to draw.

The property Handle of a control Canvas isn't always set to a device
context handle. "Delphi" set this property "only" when a paint message is
received by the control so you can use the property in the overrided paint
procedure.The handle is released after the execution of the paint
procedure.

If you have to draw outside the paint procedure you have to use the API
fonctions GETDC and RELEASEDC to retrieve and release a valid device
context that you can set to canvas.handle .

Have a look to the file "Doc\Consts.int" in Delphi Directory. You will find
there the variables that are defined for this error message
(SNoCanvasHandle) and for other messages. Then you just have to search for
the variable in Delphi's source to know why it comes up....

Tom Conlon <t...@2ls.com> a crit dans l'article
<909830319.20814.0.nnrp-05.c1ed2...@news.demon.co.uk>...

Quote
> Can anyone throw any light on the above error message that comes up with
one
> of our custom components?

> Thanks,

> Tom

Other Threads