Page 1 of 1
Get Windows position from CAD VCL Position
Posted: 18 May 2021, 12:32
by LisichkinAlexander
Hello!
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;
With respect,
Alexander.
Re: Get Windows position from CAD VCL Position
Posted: 18 May 2021, 22:05
by support
Hello Alexander,
You may use a TsgCADImage.GetPoint function which returns TPoint value for a given TFPoint:
Code: Select all
function TsgCADImage.GetPoint(const P: TFPoint): TPoint;
Mikhail
Re: Get Windows position from CAD VCL Position
Posted: 19 May 2021, 09:54
by LisichkinAlexander
Thank you Mikhail !
I wrote the following code:
LVectorImage - object of TsgDrawingNavigator inheritor class
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
Alexander.