Board index » delphi » Error: canvas does not allow drawing

Error: canvas does not allow drawing


2003-08-21 03:50:38 AM
delphi106
Greetings all,
I am getting a "canvas does not allow drawing" error.
Does anybody know what causes this?
I am drawing 10,000 - 100,000 items to a canvas and am looking for a hint as
to where to start looking.
This comes up in a dialog box with the App name in the Window title.
If I hit OK it just keeps coming back, If I close then I get the error:
"System error. Code 87.
The parameter is incorrect"
I have no idea what is causing this.
If I repeat the same steps it does not necessarily reproduce the error.
Is it a possible resource issue?
Thanks
 
 

Re:Error: canvas does not allow drawing

Try this,
Whereever you havve a bunch of code modifying or reading canvas data, wrap
it up like this :
MyObject.Canvas.Lock;
try
// Do your stuff here
finally
MyObject.Canvas.Unlock;
end;
Let me know if it works.
regards
 

Re:Error: canvas does not allow drawing

"Leapin" <XXXX@XXXXX.COM>writes
Quote
I tried doing what you suggested in my DrawMap procedure.
(Try Canvas.Lock ... finally Canvas.Unlock end)
I still am getting the error.

The DrawMap procedure calls other procedure that draw on my canvas as
well..
Maybe I need to do it in each procedure I call?
I would think doing it at the top procedure would be enough.

Any other suggestions?

Canvas.Lock is only necessary when you are running multiple threads in your
application.
"Canvas does not allow drawing" means that you are trying to draw on a
canvas that does not have a handle. This can happen if you try to draw on a
window canvas before the window has a handle, or if you construct a raw
TCanvas yourself and try to draw on it. TCanvas by itself does not
implement the "backing store" or surface image - you need a bitmap or window
to draw upon.
Check your code to see if you are constructing instances of TCanvas
yourself. You should probably replace those with construction of TBitmaps
and drawing on the bitmap's canvas instead.
Check your code to see if you are drawing on a canvas in the context of a
component constructor or destructor, or unit initialization section. These
execute before the component/control has a useable window handle.
If you are drawing onto a control canvas, make sure the control is visible,
make sure it is Parent property is set, and its parent is visible, etc.
-Danny
 

Re:Error: canvas does not allow drawing

On 26-Aug-03, Danny Thorpe said:
Quote
Are you running on Win9x?
You call Win9x running??? <g>
--
Bill
--------
"To compel a man to furnish funds for the propagation of ideas he
disbelieves and abhors is sinful and tyrannical." -- Thomas Jefferson
 

Re:Error: canvas does not allow drawing

running on W2K
<William Meyer>writes news:XXXX@XXXXX.COM...
Quote
On 26-Aug-03, Danny Thorpe said:

>Are you running on Win9x?

You call Win9x running??? <g>

--
Bill
--------

"To compel a man to furnish funds for the propagation of ideas he
disbelieves and abhors is sinful and tyrannical." -- Thomas Jefferson