Hi Wizard,
You can make the controls appear, but its very clunky and suffers from flicker.
[pascal]
procedure TForm1.Button1Click(Sender: TObject);
begin
try
fShape.free;
except
end;
fShape:=TShape.create(dxdraw1);
fShape.parent:=dxdraw1;
fShape.top:=10;
fShape.left:=10;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
fShape.free;
except
end;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
var
loop : integer;
begin
inc(fx);
if (fx>100) then
fx:=0;
if dxdraw1.CanDraw then
begin
dxdraw1.Surface.Fill(0);
dxdraw1.surface.canvas.pen.color:=clRed;
dxdraw1.surface.canvas.MoveTo(fx,0);
dxdraw1.surface.canvas.LineTo(fx,100);
dxdraw1.surface.Canvas.release;
for loop:=0 to dxdraw1.ComponentCount-1 do
if (dxdraw1.components[loop] is TControl) then
TControl(dxdraw1.components[loop]).Invalidate;
dxdraw1.Flip;
end;
end;
[/pascal]
Without the 'for loop:=0.....invalidate;' part, the component appeared once and then vanished the next frame.
This is just something I banged together to see if it could be done, and it can, but its not great. The problem is once you start flipping to a back buffer, the controls aren't redrawn because they don't get a message telling them they need to. Hence the requirement to invalidate them manullay, but the performance really does suck.
Bookmarks