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;