Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Errors - Print-Form.
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Build lazarus and fpc in ...
by
MarkMLl
[
Today
at 04:32:59 pm]
Command line compilation ...
by
DenReq
[
Today
at 04:27:50 pm]
weird sqlite error "datab...
by
Zvoni
[
Today
at 04:24:33 pm]
lazarus "Online Package M...
by
wp
[
Today
at 03:19:32 pm]
Dark mode class...
by
Wallaby
[
Today
at 02:29:05 pm]
Custom Control causes QTr...
by
zeljko
[
Today
at 02:26:17 pm]
increment filename if exi...
by
Josh
[
Today
at 02:17:36 pm]
Optimizing the counter co...
by
PascalDragon
[
Today
at 02:09:48 pm]
Interleaving nested decla...
by
PascalDragon
[
Today
at 02:01:34 pm]
Example projects window
by
dbannon
[
Today
at 01:57:22 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Errors - Print-Form. (Read 3981 times)
seghele0
Full Member
Posts: 137
Errors - Print-Form.
«
on:
December 20, 2021, 03:43:12 pm »
Found the code on Google for printing the Form.
Can someone help me to resolve the errors?
Code: Pascal
[Select]
[+]
[-]
unit
Unit1
;
{$mode objfpc}{$H+}
interface
uses
Windows
,
Classes
,
SysUtils
,
Forms
,
Controls
,
Graphics
,
Dialogs
,
ExtCtrls
,
Buttons
,
Printers
;
type
{ TForm1 }
TForm1
=
class
(
TForm
)
Panel1
:
TPanel
;
SpeedButton1
:
TSpeedButton
;
procedure
SpeedButton1Click
(
Sender
:
TObject
)
;
private
public
end
;
var
Form1
:
TForm1
;
implementation
{$R *.lfm}
{ TForm1 }
procedure
TForm1
.
SpeedButton1Click
(
Sender
:
TObject
)
;
var
MyPrinter
:
TPrinter
;
myBitMap
:
TBitMap
;
begin
myBitMap
:
=
TBitMap
.
Create
;
myBitMap
.
Height
:
=
form1
.
Height
;
form1
.
BorderStyle
:
=
bsNone
;
form1
.
PaintTo
(
myBitMap
.
Canvas
,
0
,
0
)
;
form1
.
BorderStyle
:
=
bsSingle
;
MyPrinter
:
=
Printer
;
MyPrinter
.
BeginDoc
;
myPrinter
.
Canvas
.
CopyRect
(
Classes
.
Rect
(
0
,
0
,
RoundToInt
(
myPrinter
.
PaperSize
.
Width
/
2
)
,
RoundToInt
(
myPrinter
.
PaperSize
.
Height
/
2
)
)
,
myBitMap
.
Canvas
,
Classes
.
Rect
(
0
,
0
,
myBitMap
.
Width
,
myBitMap
.
Height
)
)
;
MyPrinter
.
EndDoc
;
myBitMap
.
Free
;
end
;
end
.
The errors:
Code: Pascal
[Select]
[+]
[-]
Compile Project
,
Target
:
project1
.
exe
:
Exit code
1
,
Errors
:
2
unit1
.
pas
(
46
,
11
)
Error
:
Identifier
not
found "RoundToInt"
unit1
.
pas
(
47
,
11
)
Error
:
Identifier
not
found "RoundToInt"
Logged
VisualLab
New Member
Posts: 26
Re: Errors - Print-Form.
«
Reply #1 on:
December 20, 2021, 04:12:32 pm »
"Round" instead "RoundToInt".
Logged
seghele0
Full Member
Posts: 137
Re: Errors - Print-Form.
«
Reply #2 on:
December 20, 2021, 04:49:29 pm »
Thank you for the info.
Compiling is OK, but still ERROR after running the program.
Logged
winni
Hero Member
Posts: 3045
Re: Errors - Print-Form.
«
Reply #3 on:
December 20, 2021, 04:56:19 pm »
Hi!
The Lazarus printing trap:
The compiler does not complain, but you need the unit
Printer4Lazarus
for printing.
PS.: Fastet gun in the west: Jamie
Winni
Logged
seghele0
Full Member
Posts: 137
Re: Errors - Print-Form.
«
Reply #4 on:
December 20, 2021, 05:55:51 pm »
I've add Printer4Lazarus in the Project inspector.
Compiling is still OK.
After "run", the printer works, but only a blank page.
???
Logged
VisualLab
New Member
Posts: 26
Re: Errors - Print-Form.
«
Reply #5 on:
December 20, 2021, 05:59:54 pm »
The code is missing an instruction to specify the width of the printed bitmap. Add:
Code: Pascal
[Select]
[+]
[-]
LMyBitmap
.
Width
:
=
Form1
.
Width
;
Logged
seghele0
Full Member
Posts: 137
Re: Errors - Print-Form.
«
Reply #6 on:
December 20, 2021, 06:07:58 pm »
THANK YOU.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Errors - Print-Form.
TinyPortal
© 2005-2018