Dynamic TAnnotationTool Autosize=false makes text disappear?
Posted: Wed Mar 04, 2009 4:30 am
Hi Steema,
I am new to the TAnnotationTool but I have found an interesting problem. If I use the following code it works fine.
TMYForm.FormCreate ;
begin
SetLength(SieveAnnotation,12) ;
for i := 0 to 11 do
begin
SieveAnnotation := TAnnotationTool.Create(self) ;
SieveAnnotation.Brush.Color:=clWhite;
SieveAnnotation.Shape.Transparency:=0;
if i = 0 then
SieveAnnotation.Text:='COBBLES';
if i = 1 then
SieveAnnotation.Text:='COARSE GRAVEL';
if i = 2 then
SieveAnnotation.Text:='MEDIUM GRAVEL';
if i = 3 then
SieveAnnotation.Text:='FINE GRAVEL';
if i = 4 then
SieveAnnotation.Text:='COARSE SAND';
if i = 5 then
SieveAnnotation.Text:='MEDIUM SAND';
if i = 6 then
SieveAnnotation.Text:='FINE SAND';
if i = 7 then
SieveAnnotation[i].Text:='COARSE SILT';
if i = 8 then
SieveAnnotation[i].Text:='MEDIUM SILT';
if i = 9 then
SieveAnnotation[i].Text:='FINE SILT';
if i = 10 then
SieveAnnotation[i].Text:='CLAY';
end;
for i := 0 to 10 do
begin
SieveAnnotation[i].Active := true ;
chPSD1.Tools.Add(SieveAnnotation[i]);
end;
end;
TMyForm.chPSD1AfterDraw(Sender: TObject);
begin
With chPSD1 do
Begin
LeftVal := chPSD1.BottomAxis.CalcPosValue(60) ;
TopVal := chPSD1.LeftAxis.IStartPos - 15 ;
RightVal := chPSD1.BottomAxis.IEndPos;
BottomVal := chPSD1.LeftAxis.IStartPos ;
SieveAnnotation[0].PositionUnits:=muPixels;
// SieveAnnotation[0].Shape.AutoSize := false ;
SieveAnnotation[0].Shape.Left:=LeftVal;
SieveAnnotation[0].Shape.Top:=TopVal;
SieveAnnotation[0].Shape.Width:=RightVal-LeftVal;
SieveAnnotation[0].Shape.Height:=TopVal-BottomVal;
end;
If I use the code above then it works fine. However if I uncomment the line in the AfterDraw procedure then it only shows me blank boxes but they are the correct width. My bottomaxis is also Logarithmic if that helps.
Can you shed any light for me on what is going wrong here ?
I am new to the TAnnotationTool but I have found an interesting problem. If I use the following code it works fine.
TMYForm.FormCreate ;
begin
SetLength(SieveAnnotation,12) ;
for i := 0 to 11 do
begin
SieveAnnotation := TAnnotationTool.Create(self) ;
SieveAnnotation.Brush.Color:=clWhite;
SieveAnnotation.Shape.Transparency:=0;
if i = 0 then
SieveAnnotation.Text:='COBBLES';
if i = 1 then
SieveAnnotation.Text:='COARSE GRAVEL';
if i = 2 then
SieveAnnotation.Text:='MEDIUM GRAVEL';
if i = 3 then
SieveAnnotation.Text:='FINE GRAVEL';
if i = 4 then
SieveAnnotation.Text:='COARSE SAND';
if i = 5 then
SieveAnnotation.Text:='MEDIUM SAND';
if i = 6 then
SieveAnnotation.Text:='FINE SAND';
if i = 7 then
SieveAnnotation[i].Text:='COARSE SILT';
if i = 8 then
SieveAnnotation[i].Text:='MEDIUM SILT';
if i = 9 then
SieveAnnotation[i].Text:='FINE SILT';
if i = 10 then
SieveAnnotation[i].Text:='CLAY';
end;
for i := 0 to 10 do
begin
SieveAnnotation[i].Active := true ;
chPSD1.Tools.Add(SieveAnnotation[i]);
end;
end;
TMyForm.chPSD1AfterDraw(Sender: TObject);
begin
With chPSD1 do
Begin
LeftVal := chPSD1.BottomAxis.CalcPosValue(60) ;
TopVal := chPSD1.LeftAxis.IStartPos - 15 ;
RightVal := chPSD1.BottomAxis.IEndPos;
BottomVal := chPSD1.LeftAxis.IStartPos ;
SieveAnnotation[0].PositionUnits:=muPixels;
// SieveAnnotation[0].Shape.AutoSize := false ;
SieveAnnotation[0].Shape.Left:=LeftVal;
SieveAnnotation[0].Shape.Top:=TopVal;
SieveAnnotation[0].Shape.Width:=RightVal-LeftVal;
SieveAnnotation[0].Shape.Height:=TopVal-BottomVal;
end;
If I use the code above then it works fine. However if I uncomment the line in the AfterDraw procedure then it only shows me blank boxes but they are the correct width. My bottomaxis is also Logarithmic if that helps.
Can you shed any light for me on what is going wrong here ?