- Posts: 3
- Thank you received: 0
×
CodeTyphon MS Windows (XP, Vista, Win7, Win8.x and Win10) OS Development, discussions and problems
Question Printing
- Leo Seghers
- Topic Author
- Offline
- New Member
-
Less
More
9 months 2 days ago #14629
by Leo Seghers
Printing was created by Leo Seghers
Hello,
I’m no programmer, so my knowledge about programming is very poor.
When using CT 5.5 I had no problem of printing the following procedure.
Now, I installed CT 7.1 and the printer stays on hold.
There are no errors when compiling en building the program.
The main question is simple, I just want to print a form.
Could you please help me?
I’m no programmer, so my knowledge about programming is very poor.
When using CT 5.5 I had no problem of printing the following procedure.
Now, I installed CT 7.1 and the printer stays on hold.
There are no errors when compiling en building the program.
The main question is simple, I just want to print a form.
Could you please help me?
//***
Uses
LCLIntf, LCLType, LCLProc,
LR_Class, LResources,
Windows, SysUtils, Classes, Clipbrd,StdCtrls,
Controls, Forms, Dialogs, ExtCtrls,
Buttons, Menus,
sqlite3dyn, sqlite3conn, sqldb, db, DbCtrls, DBGrids,
DateUtils, FileUtil,
Variants, Printers, OSPrinters, RTTICtrls,
IntfGraphics, GraphType, Graphics, Types;
//***
procedure TFviewer.PrintForm(centredOnPage: boolean; anOrientation: TPrinterOrientation);
var
VARmyBitMap: TBitMap;
VARprnBmp: TBitmap;
VARprnRct: TRect;
VARHScaleFactor: Single;
VARVScaleFactor: Single;
VARaLeft: Integer;
VARaTop: Integer;
VARaSize: TSize;
begin
Try
VARHScaleFactor:=Printer.XDPI/Screen.PixelsPerInch;
VARVScaleFactor:=Printer.YDPI/Screen.PixelsPerInch;
VARmyBitMap:= TBitMap.Create;
VARprnBmp:=TBitmap.Create;
try
Printer.Orientation:=anOrientation;
VARmyBitMap.LoadFromDevice(Canvas.Handle);
VARprnBmp.SetSize(trunc(VARmyBitMap.Width*VARHScaleFactor),
trunc(VARmyBitMap.Height*VARVScaleFactor));
VARprnRct:=Rect(0, 0, VARprnBmp.Width, VARprnBmp.Height);
VARprnBmp.Canvas.StretchDraw(VARprnRct, VARmyBitMap);
if centredOnPage then
begin
VARaSize:=Size(Printer.PaperSize.PaperRect.WorkRect);
case Printer.Orientation of
poPortrait: begin
VARaLeft:=(VARaSize.cx - VARprnBmp.Width) div 2;
VARaTop:=(VARaSize.cy - VARprnBmp.Height) div 2;
end;
poLandscape: begin
VARaTop:=(VARaSize.cy - VARprnBmp.Height) div 2;
VARaLeft:=(VARaSize.cx - VARprnBmp.Width) div 2;
end;
end;
end
else
begin
VARaLeft:=0;
VARaTop:=0;
end;
Printer.BeginDoc;
try
Printer.Canvas.Draw(VARaLeft, VARaTop, VARprnBmp);
finally
Printer.EndDoc;
end;
finally
VARmyBitMap.Free;
VARprnBmp.Free;
end;
except On E: Exception do
Begin
QuestionDlg('Error', ' ! ! ! '+#13+
'' +#13+ '' +#13+#13+ 'ERROR: '+ E.Message, mtError, [mrOk, 'DRUK HIER <--- '], '');
end;
end;
end;
//***
procedure TFviewer.BitBtnPRINTClick(Sender: TObject);
begin
PanelbtnVIEWER.Visible:=False;
Screen.cursor := crHourGlass;
Application.ProcessMessages;
Sleep(1000);
PrintForm(True, poPortrait);
//PrintForm(True, poLandscape);
Screen.Cursor := crDefault;
Application.ProcessMessages;
PanelbtnVIEWER.Visible:=True;
end;
//***
Please Log in or Create an account to join the conversation.
- Matis A.
-
- Away
- Moderator
-
- Leo Seghers
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
9 months 2 days ago #14635
by Leo Seghers
Replied by Leo Seghers on topic Printing
OS = Windows 10.
With the my old 'exe', compiled with CT 5.5, the printing of the form was always succesfull.
The must be a different approach in the new CT7.1 !! ??
With the my old 'exe', compiled with CT 5.5, the printing of the form was always succesfull.
The must be a different approach in the new CT7.1 !! ??

Please Log in or Create an account to join the conversation.
- Matis A.
-
- Away
- Moderator
-
9 months 1 day ago - 9 months 1 day ago #14636
by Matis A.
PilotLogic Core Programmer
Replied by Matis A. on topic Printing
We release CT ver 5.50 at 18-Sep-2015,
many many things changed in last 5 years ...
Because I can't test your full Source and
all are looks OK to me in your posted source,
please look the CodeOcean sample at:
C:\codetyphon\CodeOcean\lz_Printers\samples\dialogs\selectprinter.ctpr
many many things changed in last 5 years ...

Because I can't test your full Source and
all are looks OK to me in your posted source,
please look the CodeOcean sample at:
C:\codetyphon\CodeOcean\lz_Printers\samples\dialogs\selectprinter.ctpr
PilotLogic Core Programmer
Last edit: 9 months 1 day ago by Matis A..
Please Log in or Create an account to join the conversation.
- Leo Seghers
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
9 months 1 day ago #14641
by Leo Seghers
Replied by Leo Seghers on topic Printing
Thank you for the information.
Please Log in or Create an account to join the conversation.