ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Unable to Print
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - Oct 06 2024 :  06:22:52  Show Profile  Reply
Hi

I am using v8 of ImageEN, and I wrote some code ten or more years ago to print a BMP from a TImagENView component that worked well for a number of years.

I tend to use screenshots rather than hard copies these days, so it's been on my bug list to fix for a long while, and although I can initiate printing, Windows 10 always reports a printing error.

I notice in the latest version you can now print directly from an IEBitmap but unfortunately I'm stuck with what I have.

All I can assume is that something happened in Windows and you can't print from v8 anymore.

Any suggestions for a work round are welcome#128521;

Bruce.


procedure PrintControl(AControl: TWinControl; Title: string =''; Shadow: boolean = True);
var
  bmp : TBitMap;
  DC  : HDC;
  img : TImageEnView;
  dlg : TPrinterSetupDialog;
begin
  bmp:=TBitmap.Create;

  try
    bmp.Width:=AControl.ClientWidth;
    bmp.Height:=AControl.ClientHeight;
    bmp.PixelFormat:=pf24bit;

    DC:=GetWindowDC(AControl.Handle);

    try
      BitBlt(bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,DC,0,0,SrcCopy);

      bmp.Canvas.Brush.Color:=clBlack;
      bmp.Canvas.FrameRect(rect(0,0,bmp.Width,bmp.Height));

      img:=TImageEnView.Create(nil);

      try
        img.Bitmap.Assign(bmp);

        if Shadow then
          img.Proc.AddSoftShadow(2,10,10,True,clBlack,80);

        dlg:=TPrinterSetupDialog.Create(nil);

        try
          if dlg.Execute then
          begin
            // Print the image in the center of the page stretched to page dimensions
            Printer.BeginDoc;

            try
              Printer.Title:=Title;
              img.IO.PrintImage(Printer.Canvas,0,0,0,0,ievpCenter,iehpCenter,iesFitToPage,0,0,1);
            finally
              Printer.EndDoc;
            end;
          end;
        finally
          dlg.Free;
        end;
      finally
        img.Free
      end;
    finally
      ReleaseDC(AControl.Handle,DC);
    end;
  finally
    bmp.Free
  end;
end;

xequte

38531 Posts

Posted - Oct 06 2024 :  15:55:09  Show Profile  Reply
Hi Bruce

We're going to need more information to help you here. Do you get any error message? Have you tried stepping into ImageEn code to see where it fails?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Oct 14 2024 :  11:03:16  Show Profile  Reply
Hi Nigel

I've just traced the code and it balked when it got to here.

Believe it or not despite a search I don't have a copy of Winapi.Windows.pas on my Pc so can't go any further.

I'm running Delphi 10.2.

Bruce.




Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Oct 14 2024 :  11:06:02  Show Profile  Reply
I have run across missing paths to files before on my PC but not missing files.
I had to set the path to pick up vcl.printers.pas before I could get that far!
Go to Top of Page

xequte

38531 Posts

Posted - Oct 14 2024 :  17:32:22  Show Profile  Reply
Hi

I'm not sure those files are actually missing, otherwise your application wouldn't compile at all. When stepping through the code, I would just ignore those units. You want to find the ImageEn line where the printing code fails to process as you would expect.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: