Zoom in a box

Discuss and ask questions about CAD DLL (CAD Image DLL, CAD Importer DLL).

Moderators: SDS, support, admin

Post Reply
Borni
Posts: 6
Joined: 11 Jul 2007, 16:13

Zoom in a box

Post by Borni » 04 Feb 2008, 19:21

Hi,

we want to paint an zooming-area in a separat box.
The rectangle for the zoom-area is not the problem, but the method for calculated !!! ( Our example is not exactly )

for example:
iXw - Width of the select-box
AnchorX - LeftCorner of the s.b.
curX - RightCorner of the s.b.

iXw := pbImage.clientREct.Right;
FScale := iXw / (Curx - AnchorX) * FScale ;
fx := round(FScale / 100 * (-1)*(AnchorX-fx));
fy := round(FScale / 100 * (-1)*(AnchorY-fy));
pbImage.Invalidate;

Can you help us ?

( Delphi 2007, CadImageDLL)

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

Post by support » 06 Feb 2008, 16:34

Hi!

The following example is based on <b>DemoDelphi</b> from the CADImage.DLL package (Web page: http://www.cadsofttools.com/en/products ... e_dll.html).

<ul><li>1. Add new form to the project.</li>
<li>2. Add the following lines:

Code: Select all

<b>uses</b>
  ... sgcadimage;

  TForm2 = <b>class</b>(TForm)
    ...
  <b>public</b>
    FImgRect: TRect;
    FParentRect: TRect;
    FX: Integer;
    FY: Integer;
  ...

<b>implementation

uses</b>
  fMain, Types;
</li>
<li>3. Add OnPaint handler:

Code: Select all

<b>procedure</b> TForm2.FormPaint(Sender: TObject);
<b>var</b>
  vRect: TRect;
  vScale: Integer;
<b>begin</b>
  vScale := 4;
  vRect := FImgRect;
  vRect.Left := (vRect.Left * vScale - (FX * vScale - Form2.Width <b>div</b> 2));
  vRect.Right := (vRect.Right * vScale - (FX * vScale - Form2.Width <b>div</b> 2));
  vRect.Top := (vRect.Top * vScale - (FY * vScale - Form2.Height <b>div</b> 2));
  vRect.Bottom := (vRect.Bottom * vScale- (FY * vScale - Form2.Height <b>div</b> 2));
  DrawCAD(CADFile, Form2.Canvas.Handle, vRect);
<b>end</b>;
</li>
<li>4. Open fMain.pas module.</li>
<li>5. Add at the end of procedure TfmMain.pbImagePaint:

Code: Select all

  Form2.FImgRect := vRect;
</li>
<li>6. Add at the beginning of procedure TfmMain.pbImageMouseMove:

Code: Select all

  Form2.FX := X;
  Form2.FY := Y;
  Form2.Invalidate;
</li></ul>
Sergey

Please post questions to the forum or write to support@cadsofttools.com

Borni
Posts: 6
Joined: 11 Jul 2007, 16:13

Post by Borni » 06 Feb 2008, 20:42

SUPER !!!![:)]

Thanks !!!!!

Best regards

Post Reply