Get Windows position from CAD VCL Position

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
LisichkinAlexander
Posts: 2
Joined: 18 May 2021, 12:24

Get Windows position from CAD VCL Position

Post by LisichkinAlexander » 18 May 2021, 12:32

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.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Get Windows position from CAD VCL Position

Post by support » 18 May 2021, 22:05

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

LisichkinAlexander
Posts: 2
Joined: 18 May 2021, 12:24

Re: Get Windows position from CAD VCL Position

Post by LisichkinAlexander » 19 May 2021, 09:54

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.

Post Reply