Unit Prtgrid |
PRTGRID.PAS -- TPrintGrid v3.0. This is a Delphi v1 component that lets you print a DBGrid. Public domain by E. Engler. Nov 14, 1996. This version has many bugs fixes and some new properties and methods, and has been structurally reorganized to separate "printing to file" vs. "printing to printer". The code is much cleaner after making this separation. User can select DPI and Orientation using the std printer configuration dialog. As this code is now, there will be slight variances in sizing and proportions for different DPI settings, but it will look acceptable. I have tested with 300 and 600 DPI laser printers, but I haven't tested with 1200 DPI yet. I think the user can chg printers via the dialog at run time and this will still work OK, but I haven't tested this. This will need modifications if you modify a DBGrid to allow multi-row column headers or data values (or if you embed bitmaps), but most owner-draw code added to the grid to control colors won't conflict with this component. By the way: this component goes along nicely with the TDBSearch component, which searches for text in grids. *) (* to do: 1. chg HorizGap to a percentage of a char size using detail line font 2. Although VertGapPct is already supposed to be based on a percent of char size, I had to tweak it in a DPI-dependant manner to get reasonable sizing at both 300 and 600 DPI. Why? 3. Change margin specs to a DPI-independant measurement, instead of pixel counts (perhaps keyed to detail font char size; or if you feel agressive, tie them to inches. Pay attention to Orientation and paper size differences). 4. Make sure that all sizing formulas produce identically- sized and proportioned reports at both 300 DPI and 600 DPI (and up!). As I said, this now works much better but it's output isn't identically sized at 300 and 600. 5. Automatically default Orientation depending on how wide the grid is. Also, perhaps you want to use larger fonts for the printed report if the screen grid is small. Maybe call this an "autolayout" property? 6. Perhaps the "Print to File" option should bring up a dialog box giving format options like quoted comma-separated fields, etc.
Classes |
Functions |
Register -
Types |
Constants |
Variables |
Functions |
Types |
TPageNumberPos = (pnNone, pnTopLeft, pnTopCenter, pnTopRight, pnBotLeft, pnBotCenter, pnBotRight);
Constants |
Variables |