destructor TDirectDrawCanvas.Destroy; begin Release; inherited; end;
procedure TDirectDrawCanvas.Release; begin if FDeviceContext <> 0 then begin Handle := 0; FSurface.ReleaseDC(FDeviceContext); FDeviceContext := 0; end; end;
procedure TDirectDrawCanvas.CreateHandle; begin if FDeviceContext = 0 then begin FEnabled := FSurface.GetDC(FDeviceContext) = DD_OK; if FEnabled then Handle := FDeviceContext else begin Handle := 0; FDeviceContext := 0; end; end; end;
使い方は Canvas := TCanvas.Create(BackBufferSurface); しておいて with Canvas do if Enabled then try Pen.Style := psSolid; : finally Release; end;