Get Windows position from CAD VCL Position
Moderators: SDS, support, admin
-
- Posts: 2
- Joined: 18 May 2021, 12:24
Get Windows position from CAD VCL Position
Hello!
How I can get Windows point position from CAD VCL TFPoint ?With respect,
Alexander.
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.
Re: Get Windows position from CAD VCL Position
Hello Alexander,
You may use a TsgCADImage.GetPoint function which returns TPoint value for a given TFPoint:
Mikhail
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;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 2
- Joined: 18 May 2021, 12:24
Re: Get Windows position from CAD VCL Position
Thank you Mikhail !
I wrote the following code:
LVectorImage - object of TsgDrawingNavigator inheritor class
Alexander.
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.