Hello,
I would like to use
TsgDXFImage.DrawRect(DC: HDC; SourceRect: TFRect; DestRect: TRect)
to print out a rectangular region of a DWG-file. Could you give me a small example? I have tried it but I get an access violation in DXFImage.pas, procedure DrawRect at line 1954 (this comes from EurekaLog, the error tracking software I use).
Thanks
Question to TsgDXFImage.DrawRect
Moderators: SDS, support, admin
Hello!
Please try the following code:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please try the following code:
Code: Select all
<b>procedure</b> TMyApp.Forum_311_ButtonClick(Sender: TObject);
<b>const</b> PO: <b>array</b>[Boolean] <b>of</b> TPrinterOrientation = (poPortrait,poLandscape);
<b>var</b>
Img: TsgDXFImage;
FR: TFRect;
R: TRect;
<b>begin
if</b> OpenDialog1.Execute <b>then</b>
sgImage1.LoadFromFile(OpenDialog1.Filename);
<b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then
begin</b>
sgImage1.Align := alClient;
Img := TsgDXFImage(sgImage1.Picture.Graphic);
<b>end
else
begin</b>
Img := <b>nil</b>;
Exit;
<b>end</b>;
<b>with</b> sgImage1.Picture <b>do</b>
Printer.Orientation := PO[Width > Height];
<b>if</b> PrintDialog1.Execute <b>then
begin</b>
FR := Img.Extents;
Printer.BeginDoc;
FR := MakeFRect(FR.Left + (FR.Right - FR.Left) * 0.125,
FR.Bottom + (FR.Top - FR.Bottom)* 0.125,
FR.Z1 + (FR.Z2 - FR.Z1) * 0.125,
FR.Left + (FR.Right - FR.Left) * 0.875,
FR.Bottom + (FR.Top - FR.Bottom)* 0.875,
FR.Z1 + (FR.Z2 - FR.Z1) * 0.875);
R := Printer.Canvas.ClipRect;
Img.DrawRect(Printer.Canvas.Handle, FR, R);
Printer.EndDoc;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com