Board index » delphi » canvas does not allow drawing

canvas does not allow drawing

Hi,

on some computers my D3 written program rises a error 'canvas does not
allow drawing'. What can i do to avoid this bug?
Bernd.

 

Re:canvas does not allow drawing


"Quivis" <qui...@ask.me.first> skrev i melding
news:MPG.15b29af6d1bf6aea98a02c@207.14.113.10...

Quote
> On Sat, 07 Jul 2001 22:48:35 +0200, Bernd Karle had this to say...

> -> Hi,
> ->
> -> on some computers my D3 written program rises a error 'canvas does not
> -> allow drawing'. What can i do to avoid this bug?
> -> Bernd.

> Sorry, no answer to your problem in here, but if you find the answer,
> I'd like to hear about it, too. I had the same problem with a
> component I found, and which refused to work properly in D5, so I had
> to toss it out, sadly. I asked about it in the group some time ago and
> got no relevant answers back, so I assume no one knows what goes on.

This is an error frequently seen with poorly written controls. The exception
is a delphi-created one, when the canvas does not have a valid handle. I'm
not 100% sure, but I guess this happens when the control is not properly
initialized, often caused by an exception in the creation process. ISTM that
it's even easier to get this error at designtime with a custom created
control (because all stuff done to a control is done when the control is
visible).

It may also happen when you're out of GUI resources (Win9x).
--
Bjoerge Saether
Consultant / Developer
http://www.itte.no
Asker, Norway
bjorgeremovet...@itte.no (remove the obvious)

Re:canvas does not allow drawing


Quote
"Bj?rge S?ther" <REMOVE_bsaether@THIS_online.no> wrote in message

news:sx527.4072$Jp5.62745@news1.oke.nextra.no...

Quote
> "Quivis" <qui...@ask.me.first> skrev i melding
> news:MPG.15b29af6d1bf6aea98a02c@207.14.113.10...
> > On Sat, 07 Jul 2001 22:48:35 +0200, Bernd Karle had this to say...

> > -> Hi,
> > ->
> > -> on some computers my D3 written program rises a error 'canvas does
not
> > -> allow drawing'. What can i do to avoid this bug?
> > -> Bernd.

> > Sorry, no answer to your problem in here, but if you find the answer,
> > I'd like to hear about it, too. I had the same problem with a
> > component I found, and which refused to work properly in D5, so I had
> > to toss it out, sadly. I asked about it in the group some time ago and
> > got no relevant answers back, so I assume no one knows what goes on.

> This is an error frequently seen with poorly written controls. The
exception
> is a delphi-created one, when the canvas does not have a valid handle. I'm
> not 100% sure, but I guess this happens when the control is not properly
> initialized, often caused by an exception in the creation process. ISTM
that
> it's even easier to get this error at designtime with a custom created
> control (because all stuff done to a control is done when the control is
> visible).

> It may also happen when you're out of GUI resources (Win9x).

It happens during form creation when the form tries to do something that
involves a control's canvas before its handle has been created. I'd check
the form's OnCreate event and the constructors of any custom components.

Re:canvas does not allow drawing


I don't think that your application contains bugs. The error 'Canvas does
not allow drawing' is very often the result of a lack of user resources (use
the Resource Meter to check).

Some tips on how to reduce resource usage:
- Don't auto-create forms. Create them if you need them and destroy them if
you're done.
- Don't put to many controls on a single form. Move less used controls to a
second form that is shown when you click a button (or something like
that...).
- Avoid using TComboBox (and TDBComboBox etc.). These components use 3 times
as much resources as other components.

"Bernd Karle" <f...@gmx.net> schreef in bericht
news:0dtekt8ubbl3410m29g73tuo8j1if7e33h@4ax.com...

Quote
> Hi,

> on some computers my D3 written program rises a error 'canvas does not
> allow drawing'. What can i do to avoid this bug?
> Bernd.

Re:canvas does not allow drawing


The message <0dtekt8ubbl3410m29g73tuo8j1if7e...@4ax.com>
  from  Bernd Karle <f...@gmx.net> contains these words:

Quote
> Hi,
> on some computers my D3 written program rises a error 'canvas does not
> allow drawing'. What can i do to avoid this bug?
> Bernd.

Check on the delphi bugs list

http://www.jrsoftware.org/buglist/bugsall.htm

The Delphi 3.02 version still has some memory leaks
in graphics.pas which can lead to out of resources.

--
Sincerely,

Andreas Kyriacou
----------------
http://www.andrikkos.co.uk (Imagine! Image Viewer)

Re:canvas does not allow drawing


"Quivis" <qui...@ask.me.first> skrev i melding
news:MPG.15b44f51b69b8c7b98a02e@207.14.113.10...

Quote
> On Sun, 8 Jul 2001 23:13:12 +0200, Bj?rge S?ther had this to say...

> -> > to toss it out, sadly. I asked about it in the group some time ago and
> -> > got no relevant answers back, so I assume no one knows what goes on.
> ->
> -> This is an error frequently seen with poorly written controls. The
exception
> -> is a delphi-created one, when the canvas does not have a valid handle.
I'm
> -> not 100% sure, but I guess this happens when the control is not properly
> -> initialized, often caused by an exception in the creation process. ISTM
that
> -> it's even easier to get this error at designtime with a custom created
> -> control (because all stuff done to a control is done when the control is
> -> visible).
> ->
> -> It may also happen when you're out of GUI resources (Win9x).

> As you say, this error occurred while designing the GUI, dropping a
> component on a blank form, then switching to the code editor and
> switching back to the form lead to this error. So, in essence, when
> the form was repainting itself after it had been hidden the error
> occurred. The mystery is that it didn't do this at the time I dropped
> the component on the form. Initial painting seems ok. Repainting goes
> berserk, for every icon in the component in need of repainting. But it
> still updates the icons! Doing this for a couple of time makes Delphi
> unstable and after a few more times there is an internal Delphi error,
> which, according to the help file, "you should never get..."

This problem is typical for a control writer who doesn't understand all of
the message flow and handle/device context stuff of a Windows control. It's
complicated, so I don't blame anyone. And - I make such mistakes from time to
time myself. It's a "what-goes-where" - problem, a piece of code involving
canvas access placed where it should not be.

The reason it crashes after setting a propert is probably that the control
handle is recreated as a result of this setting. This is something that
rarely occurs except when designing. Writing a control that works runtime is
half as hard as making it bugfree in design mode. The reasons are: a) You
don't have debugging available for the code run by the form designer, and b)
you need to know the requirements and fundamentals of the designer as well.

Back to your control: You may email me the code, describe how you make the b
ug appear, and I'll have a look at it.

--
Bjoerge Saether
Consultant / Developer
http://www.itte.no
Asker, Norway
bjorgeremovet...@itte.no (remove the obvious)

Re:canvas does not allow drawing


Hi, I have had this problem when some graphic components (like
tgifimage) try to draw when the system is very low on resources, if
there are a lot of other memory greedy programs running.  Instead of a
out of memory message, I get 'canvas does not allow drawing - as if
it's not initilaised or something has failed during the setup.

I have reduced the immediate memory requirements of my app by using
'free' when I can, and avoid filling my taskbar with microsoft
stuff.....

Quote
On Sun, 8 Jul 2001 17:30:18 +0200, Quivis <qui...@ask.me.first> wrote:
>On Sat, 07 Jul 2001 22:48:35 +0200, Bernd Karle had this to say...

>-> Hi,
>->
>-> on some computers my D3 written program rises a error 'canvas does not
>-> allow drawing'. What can i do to avoid this bug?
>-> Bernd.

>Sorry, no answer to your problem in here, but if you find the answer,
>I'd like to hear about it, too. I had the same problem with a
>component I found, and which refused to work properly in D5, so I had
>to toss it out, sadly. I asked about it in the group some time ago and
>got no relevant answers back, so I assume no one knows what goes on.

>Could be any number of things, I guess. From bad coding to
>faulty and/or outdated system DLLs. Take your pick! ;-)

>Quivis.
>--
>SPAM goes here : root@localhost
>Freeware       : Revix (indexing, renaming, personalizing of images)
>Web Space      : http://hem.passagen.se/quivis/index.html

Other Threads