Original Post
I have a big problem with using an additional DelphiX TDirectDrawSurface in my game :
I have a ''MissileSurface'' in my game thats used as a static painting ground for missile trails, this surface is described to the main DXDraw surface in the DXTimer loop.
The problem is that everything works fine until someone alt-tabs out of the game into windows and then returns later. After they return as soon as the MissileSurface is drawn to (using the canvas property, example:
Gameform.MissileSurface.Canvas.Pen.Color := Colour[ColourIndex];
Gameform.MissileSurface.Canvas.MoveTo(Trunc(ox), Trunc(oy));
Gameform.MissileSurface.Canvas.LineTo(Trunc(x), Trunc(y));
Gameform.MissileSurface.Canvas.Release;
It creates an error in the Graphics.pas in the
procedure TCanvas.RequiredState(ReqState: TCanvasState);
..procedure at this line :
if FHandle = 0 then
raise EInvalidOperation.CreateRes(@SNoCanvasHandle);
I find this strange because if I don''t use the missile canvas, alt-tab out and then re-tab in, it will keep playing until the above missile canvas code is called, and then it gives that error. If I comment out the missile canvas code no errors are raised but then no missiles are drawn either
I''ve tried all sorts of DXDraw.CanDraw protections etc but to no avail
I''m, really annoyed that I can''t alt-tab my game.
I''m really confused! My MissileSurface varible is solid and is being created on a DXDraw.Initialize event and destoryed on finalised, but my debug logs report that none of these are being called during the alt-tab switch, so i''m just really confused.
I relise it''s really hard for you ti try to help me with out actually having the code, but i''m hoping that maybe i''m running into a problem someone else has had.
I can give more details if possible.
Cheers!
Chuck