Nigel
Thanks for the reply, but I am still missing something. Actually, I suspect it relates to your comments about invalidating the control.
Using the ImageEn AdvancedText demo I have added the two procedures below.
procedure TForm1.ImageEnVect1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
tempCurrent_X := X;
tempCurrent_Y := Y;
if tempDisplayCurrentPosition = True then // variable attached to the Down property of a SpeedButton
begin
EditCurrentX.Text := IntToStr(tempCurrent_X);
EditCurrentY.Text := IntToStr(tempCurrent_Y);
if ImageEnVect1.ObjectsCount >= 1 then
begin
ImageEnVect1.RemoveObject(-2);
end;
tempLastAnnot_ID := ImageEnVect1.AddNewObject(iekLINELABEL, Rect(tempCurrent_X, tempCurrent_Y,
tempCurrent_X + 150, tempCurrent_Y), clRed);
ImageEnVect1.ObjText[-2] := 'Cursor Position - X = ' + IntToStr(tempCurrent_X) + ' Y = ' + IntToStr(tempCurrent_Y);
end;
Edit1.Text := 'Cursor Position - X = ' + IntToStr(tempCurrent_X) + ' Y = ' + IntToStr(tempCurrent_Y);
end;
procedure TForm1.ImageEnVect1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect);
begin
if tempDisplayCurrentPosition = True then
begin
ACanvas.TextOut(100, 100, 'Cursor Position - X = ' + IntToStr(tempCurrent_X) + ' Y = ' + IntToStr(tempCurrent_Y));
end;
end;
Scenario A)
With the above code, both the Edit1 and ACanvas.TextOut text displays as expected. In addition. the iekLineLabel follows the cursor and displays the ObjText.
Scenario B)
If I remark out the following two lines of code in the MouseMove event, both the iekLineLable and the ACanvas.TextOut components disappear.
// tempLastAnnot_ID := ImageEnVect1.AddNewObject(iekLINELABEL, Rect(tempCurrent_X, tempCurrent_Y,
// tempCurrent_X + 150, tempCurrent_Y), clRed);
// ImageEnVect1.ObjText[-2] := 'Cursor Position - X = ' + IntToStr(tempCurrent_X) + ' Y = ' + IntToStr(tempCurrent_Y);
I suspect the answer relates to your comment about invalidation, but since the ACanvas.TextOut does not return a parameter I am stumped. Can you explain how to display and update the ACanvas.TextOut when the mouse moves without including the iekLineLabel?
TIA
John