When I use the code below I get an error: "Control '' has no parent window"??
How do i fix that error??
Can You reproduce that error??
Code: Select all
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, TeeSurfa, TeeLegendPalette;
type
TForm10 = class(TForm)
Chart1: TChart;
procedure FormShow(Sender: TObject);
Procedure SetColorPalette;
procedure InitSeries(ASeries: TCustom3DGridSeries);
function CoolColorCode(ColorValue:single):TColor;
private
{ Private declarations }
public
LegendPalette : TLegendPaletteTool;
LegendPalette2 : TLegendPaletteTool;
ColorPalette: array[0..50] of TColor;
ColorPaletteLevels: array[0..50] of double;
{ Public declarations }
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.FormShow(Sender: TObject);
var
i,j,k : integer;
begin
Chart1.RemoveAllSeries;
Chart1.FreeAllSeries();
if (LegendPalette=nil) then
LegendPalette:=TLegendPaletteTool.Create(Chart1);
Chart1.View3D := false;
Chart1.Legend.Visible := false;
Chart1.Legend.Shadow.Visible := false;
Chart1.Legend.Gradient.Visible := false;
Chart1.Color := clwhite;
Chart1.AddSeries(TColorGridSeries.Create(self));
Chart1[0].ParentChart := Chart1;
SetColorPalette;
InitSeries(TCustom3DGridSeries(Chart1[0]));
with LegendPalette do
begin
Series:=Chart1[0];
Pen.Visible:=false;
LegendPalette.Left:= Chart1.Width-LegendPalette.Width-10;
LegendPalette.Height := round(2*Chart1.Height/3);
end;
Chart1.Tools.Add(LegendPalette);
with Chart1[0] as TColorGridSeries do
begin
IrregularGrid := true;
CenteredPoints := false;
Pen.Visible := false;
end;
for i := 0 to 100-1 do
for k := 0 to 100-1 do
with Chart1[0] as TColorGridSeries do
AddXYZ(i,i*k,k);
Chart1.Title.Clear;
Chart1.Title.Text.Add('Mesh Geometry');
Chart1.Title.Font.Size := 18;
Chart1.MarginRight := 10;
LegendPalette.Left:= Chart1.Width-LegendPalette.Width-10;
LegendPalette.Height := Chart1.Height-10;
end;
Procedure TForm10.SetColorPalette;
var
i:integer;
begin
for i := Low(ColorPalette) to High(ColorPalette) do
begin
ColorPalette[i] := CoolColorCode(i/High(ColorPalette));
ColorPaletteLevels[i] := 20 + i*230/High(ColorPalette);
end;
end;
procedure TForm10.InitSeries(ASeries: TCustom3DGridSeries);
var i: Integer;
begin
ASeries.UsePalette := True;
ASeries.UseColorRange := false;
ASeries.ClearPalette;
for i := Low(ColorPalette) to High(ColorPalette) do
ASeries.AddPalette(ColorPaletteLevels[i],ColorPalette[i]);
ASeries.Repaint;
end;
function TForm10.CoolColorCode(ColorValue:single):TColor;
begin
ColorValue := 100 - ColorValue*100;
if (ColorValue < 0) then
ColorValue := 0
else if (ColorValue > 100) then
ColorValue := 100;
if ColorValue < 25 then
result := rgb(255,round(ColorValue/25*255),0)
else if ColorValue < 50 then
result := rgb(255-round((ColorValue-25)/25*255),255,0)
else if ColorValue < 75 then
result := rgb(0,255,round((ColorValue-50)/25*255))
else
result := rgb(0,255-round((ColorValue-75)/25*255),255);
end;
end.