Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
How to print a DrawGrid
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
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
UK's Online Safety Act
by
Thaddy
[
Today
at 07:54:31 pm]
Unit's name collides with...
by
ASerge
[
Today
at 07:54:24 pm]
Select cell in listview
by
Jonny
[
Today
at 07:48:55 pm]
D2Bridge Framework for La...
by
Thaddy
[
Today
at 07:42:12 pm]
using TForm.OnPaint to re...
by
robert rozee
[
Today
at 06:14:18 pm]
Drawing difference betwee...
by
Jonny
[
Today
at 05:05:54 pm]
Random ?
by
Thaddy
[
Today
at 04:43:11 pm]
Memory Safety and Object ...
by
Thaddy
[
Today
at 04:19:13 pm]
Spaces are allowed here ?
by
Thaddy
[
Today
at 04:06:29 pm]
[Solved] A Tip for beginn...
by
Ten_Mile_Hike
[
Today
at 03:55:00 pm]
Error 403 downloading wit...
by
Thaddy
[
Today
at 03:09:31 pm]
API on intranet - auth im...
by
MarkMLl
[
Today
at 02:17:27 pm]
Making sense of pparser, ...
by
Thaddy
[
Today
at 01:09:44 pm]
مشكلة في التقارير
by
nouzi
[
Today
at 12:47:27 pm]
Artificial intelligence
by
MarkMLl
[
Today
at 12:31:46 pm]
[SOLVED] Treeview flicker...
by
d7_2_laz
[
Today
at 12:13:44 pm]
No access to the wiki
by
dseligo
[
Today
at 12:01:01 pm]
SQL update statement and ...
by
Zvoni
[
Today
at 11:03:07 am]
Preparing FPC 3.2.4, poin...
by
AlexTP
[
Today
at 09:25:09 am]
IContainers
by
cdbc
[
Today
at 08:36:34 am]
Using Tesseract without i...
by
Thaddy
[
Today
at 07:41:06 am]
GR32 GR_Bindings problem
by
staratel20
[
Today
at 12:50:04 am]
(Solved) built IDE for qt...
by
HotShoe
[
Today
at 12:37:22 am]
Nested declarations insid...
by
Joanna from IRC
[
Today
at 12:29:42 am]
Install OOPsie
by
johnsg
[January 19, 2025, 10:48:06 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to print a DrawGrid (Read 1258 times)
bobonwhidbey
Hero Member
Posts: 616
How to print a DrawGrid
«
on:
December 01, 2023, 06:42:08 pm »
The TDrawGrid looks good on my monitor but I haven't figured out how to print it on the printer canvas. I think my biggest problem is getting aRect, although there's a good chance I'm going about this all wrong.
Code: Pascal
[Select]
[+]
[-]
procedure
TMyForm
.
PrintClick
(
Sender
:
TObject
)
;
var
c
,
r
:
integer
;
aRect
:
TRect
;
begin
if
PrinterSetup
.
Execute
then
begin
Printer
.
BeginDoc
;
for
c
:
=
0
to
Grid
.
ColCount
-
1
do
for
r
:
=
0
to
Grid
.
RowCount
-
1
do
begin
aRect
:
=
Grid
.
CellRect
(
c
,
r
)
;
DrawCelltoCanvas
(
Printer
.
Canvas
,
c
,
r
,
aRect
,
[
]
)
;
end
;
// for c & r
Printer
.
EndDoc
;
end
;
// printer executed
end
;
Logged
Lazarus 3.6 FPC 3.2.2 x86_64-win64-win32/win64
paweld
Hero Member
Posts: 1278
Re: How to print a DrawGrid
«
Reply #1 on:
December 01, 2023, 07:08:06 pm »
GridPrinter:
https://wiki.lazarus.freepascal.org/GridPrinter
Logged
Best regards / Pozdrawiam
paweld
bobonwhidbey
Hero Member
Posts: 616
Re: How to print a DrawGrid
«
Reply #2 on:
December 04, 2023, 04:34:00 pm »
I haven't been able to figure out how to use the GridPrinter with a TDrawGrid. The (quite good) documentation doesn't mention use with a TDrawGrid. What am I missing?
Logged
Lazarus 3.6 FPC 3.2.2 x86_64-win64-win32/win64
wp
Hero Member
Posts: 12524
Re: How to print a DrawGrid
«
Reply #3 on:
December 04, 2023, 04:42:19 pm »
I cannot remember every detail of that component, but you probably must provide a handler for the OnGetCellText event in which you tell the printer the text to be printed in a specific cell.
Or is it non-text printing you are after? In this case provide a small demo project showing the grid to be printed.
Logged
bobonwhidbey
Hero Member
Posts: 616
Re: How to print a DrawGrid
«
Reply #4 on:
December 04, 2023, 05:37:26 pm »
I am printing text but I also need to control the font name and size in each cell.
In my DrawGrid onDrawCell I use my own FillRect and TextDraw, etc. I discovered that the GridPrinter needs the OnPrintCell method. Thanks wp for getting me to look further under the hood.
Logged
Lazarus 3.6 FPC 3.2.2 x86_64-win64-win32/win64
bobonwhidbey
Hero Member
Posts: 616
Re: How to print a DrawGrid
«
Reply #5 on:
December 04, 2023, 10:31:10 pm »
One last point. How do I trigger a new page. Not needed when viewing the Grid but needed when printing. I can't use Printer.NewPage.
Logged
Lazarus 3.6 FPC 3.2.2 x86_64-win64-win32/win64
wp
Hero Member
Posts: 12524
Re: How to print a DrawGrid
«
Reply #6 on:
December 04, 2023, 11:29:20 pm »
Page breaks are determined by the component, when a row or column does not fit on the current page any more. IIRC, there is no way to manually trigger a page break. This does not mean that it's not possible, but it certainly will require some work.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
How to print a DrawGrid
TinyPortal
© 2005-2018