PDA

View Full Version : Canvas does not allow drawing error



blackvoid
16-09-2004, 07:11 PM
We are developing a strategy games with Delphi + Delphix. We use both DDraw and standard forms. The game is full screen DDraw with snormal forms on top.

The game is quite stable until I alt-tab or debug, in these cases many times I get the error message: Canvas does not allow drawing. (Debugging is a pain with this problem)

In the code this happens where we write text on the screen with textout (I know its lame, but it works fine otherwise)

We have tried putting the part in a try section with an exception that does nothing, but that did not help. We have also tried trylock, but in that case we lost all the text outputs.

How can I check whether the canvas is available or not before doing the textout?

Below is our procedure that is causing the problem.

procedure TGamesForm.SzovegKi(x,y:integer; s:string; fc:Tcolor);
begin // hova mit betuszin
with DXDraw.Surface.Canvas do begin
Font.Color := fc;
TextOut(x,y,s);
Release;
end;
end;

blackvoid
17-09-2004, 07:46 AM
Also posted here: http://www.gamedev.net/community/forums/forum.asp?forum_id=30

Useless Hacker
17-09-2004, 11:39 PM
Have you tried testing DXDraw.CanDraw first?

blackvoid
18-09-2004, 09:27 PM
THANKS! Thats the one I was looking for but at the wrong place (canvas propeties/methods).