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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Lazarus Bugfix Release 4....
by
Martin_fr
[
Today
at 11:02:41 pm]
Error with last fixes_3.2...
by
Fred vS
[
Today
at 10:49:27 pm]
TCHATGPT — An Artificial ...
by
marcelomaurinmartins@gmai
[
Today
at 10:14:50 pm]
Single and Double, Conver...
by
jamie
[
Today
at 09:44:48 pm]
Which Control should I us...
by
wp
[
Today
at 09:36:00 pm]
[New Component] ExtTabCtr...
by
d7_2_laz
[
Today
at 09:32:53 pm]
Lazarus 4.8 on Sourceforg...
by
Enos68
[
Today
at 08:00:47 pm]
Can /my/ AI help me with ...
by
microxa
[
Today
at 06:49:37 pm]
Conscious Artificial Inte...
by
Dzandaa
[
Today
at 05:59:22 pm]
If FileExists(
by
Bart
[
Today
at 05:57:26 pm]
SynEdit theme
by
Martin_fr
[
Today
at 05:17:43 pm]
docked IDE and form capti...
by
Paolo
[
Today
at 02:53:50 pm]
New version of LazMapView...
by
wp
[
Today
at 12:09:27 pm]
Very rough version of a s...
by
Hansvb
[
Today
at 11:48:04 am]
PadXml 1.1.0 – Portable A...
by
AlexanderT
[
Today
at 10:38:42 am]
Arkanoid
by
Tomi
[
Today
at 09:46:46 am]
Interesting video
by
Joanna
[
Today
at 06:24:53 am]
IndySecOpenSSL is now ava...
by
TheMouseAUS
[
Today
at 03:49:17 am]
Message CM_ShowingChanged...
by
LeP
[
Today
at 02:13:51 am]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 01:48:44 am]
[SOLVED]Program experienc...
by
Cainnech
[
Today
at 12:19:17 am]
TATTabs - how to stop a 3...
by
bobonwhidbey
[
Today
at 12:03:15 am]
If you are looking for Wi...
by
avra
[June 12, 2026, 07:37:10 pm]
Testing with 3.2.4 prepar...
by
Martin_fr
[June 12, 2026, 03:50:17 pm]
TDWEdit
by
Ed78z
[June 12, 2026, 10:20:58 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to print a DrawGrid (Read 1691 times)
bobonwhidbey
Hero Member
Posts: 632
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 4.8 FPC 3.2.2 x86_64-win64-win32/win64
paweld
Hero Member
Posts: 1641
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: 632
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 4.8 FPC 3.2.2 x86_64-win64-win32/win64
wp
Hero Member
Posts: 13569
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: 632
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 4.8 FPC 3.2.2 x86_64-win64-win32/win64
bobonwhidbey
Hero Member
Posts: 632
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 4.8 FPC 3.2.2 x86_64-win64-win32/win64
wp
Hero Member
Posts: 13569
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