How I can get Windows point position from CAD VCL TFPoint ?
Code: Select all
var
LCenter: TFPoint;
begin
LCenter := XXX.Insert.Box.CenterPoint;
LCenter -> to windows point for SetMouseCursorPos (I create UnitTest)
....
end;
Alexander.
Moderators: SDS, support, admin
Code: Select all
var
LCenter: TFPoint;
begin
LCenter := XXX.Insert.Box.CenterPoint;
LCenter -> to windows point for SetMouseCursorPos (I create UnitTest)
....
end;
Code: Select all
function TsgCADImage.GetPoint(const P: TFPoint): TPoint;
Code: Select all
var
LCenter, LPoint: TPoint;
LVectorImage: TsmVectorImageEditor;
function PtInRect(const Rect: TFRect; const P: TFPoint): Boolean;
begin
Result := (P.X >= Rect.Left) and (P.X <= Rect.Right) and (P.Y <= Rect.Top)
and (P.Y >= Rect.Bottom);
end;
begin
..............
// get point for caption
if Assigned(TsgAccessDrawingNavigator(LVectorImage).ControlTool.Img) then
begin
// use centre of the Quant
FCaptionPoint := FQuant.ViewTypeProperties[vTop].Insert.Box.CenterPoint;
LCenter := TsgAccessDrawingNavigator(LVectorImage).ControlTool.Img.GetPoint(FCaptionPoint);
end else
begin
// use centre of the VectorImage
LCenter := TPoint.Create(LVectorImage.Width div 2, LVectorImage.Height div 2);
FCaptionPoint := LVectorImage.GetDrawingInternalCoords(LCenter.X, LCenter.Y);
Assert.IsTrue(PtInRect(FQuant.ViewTypeProperties[vTop].Insert.Box, FCaptionPoint), 'Can not find point in Quant');
end;
LPoint := LVectorImage.ClientToScreen(LCenter);
SetCursorPos(LPoint.X, LPoint.Y);
// emulate creating Caption at point LPoint