Printing

M!Table provides an easy way to print a table and/or to display a print preview.
To print a table ( or to display a print preview ), use an instance of fcMTblPrintParams and define the parameters as desired. After that, pass that instance to MTblPrint.

Functions
MTblPrint
MTblPrintGetDefPrinterName
MTblPrintGetPrinterNames
MTblPrintSetupDlg

Classes
fcMTblPrintLine
fcMTblPrintLinePosText
fcMTblPrintParams

Messages
MTM_DrawItem
MTM_QueryBestCellHeight
MTM_QueryBestCellWidth
MTM_QueryBestColHdrWidth
MTM_QueryMaxColWidth
MTM_QueryMaxRowHeight
MTM_QueryMinRowHeight

Row Flags
MTBL_ROW_BLOCK_BEGIN
MTBL_ROW_BLOCK_END
MTBL_ROW_PAGEBREAK


Hints and tips

Keep successive rows together on one page
To keep successive rows together on one page, set the row flag MTBL_ROW_BLOCK_BEGIN at the first row and the row flag MTBL_ROW_BLOCK_END at the last row.
If a row with MTBL_ROW_BLOCK_BEGIN is found before a row with MTBL_ROW_BLOCK_END, the current block ends at the previous row and a new block begins.

Printing additional lines
It's possible to print additional lines, namely:

  • Title lines
    These lines are printed at the top of the the first page.
  • Page header lines
    These lines are printed at the top of every page. If it's the first page, they're printed below the title lines.
  • Page footer lines
    These lines are printed at the bottom of every page.
  • Total lines
    These lines are printed below the last table row

Use an instance of fcMTblPrintLine to define a line and add it to the appropriate line array of fcMTblPrintParams, e.g. to add page header lines:
...
Local variables
 fcMTblPrintLine: Line
 fcMTblPrintParams: Params
...
Actions
 ! Initialize the print parameters with default values
 Call Params.Init( )
 ! Inititialize the line with default values
 Call Line.Init( )
 ! Set the line's centered text
 Set Line.CenterText = "I'm a page header line"
 ! Add the line to the print parameter's page header lines
 Call Params.AddPageHeader( Line )
 ! OK, let's add another line
 Call Line.Init( )
 Set Line.CenterText = "And I'm the second page header line"
 Call Params.AddPageHeader( Line )
 ...

Lines may have several texts ( left, center, right and positioned ( see below ) ) and images ( left, center and right ). Furthermore, you can define the font size ( in relation to the table font size ), the font enhancements and the font color. And finally, you can set some flags.

Positioned texts in lines
As mentioned above, lines may have positioned texts. A positioned text is some kind of datafield with a fixed position and a size which can be fixed or dynamic. Furthermore, you can define the horizontal text justify.
Use an instance of fcMTblPrintLinePosText to define a positioned text and add it to the line, e.g.:

Local variables
 fcMTblPrintLine: Line
 fcMTblPrintLinePosText: PosText
...
Actions
 ! Inititialize the line with default values
 Call Line.Init( )
 ! Initialize the positioned text with default values
 Call PosText.Init( )
 ! Set the text
 Set PosText.Text = "I'm a positioned text"
 ! Set the position ( 10mm from the left margin )
 Set PosText.Left = 10
 ! Set a fixed width ( 50mm )
 Set PosText.Width = 50
 ! Set centered justify
 Set PosText.Justify = MTP_JFY_CENTER
 ! Add it to the line
 Line.AddPosText( PosText )
 ! OK, let's add another positioned text
 PosText.Init( )
 Set PosText.Text = "I'm another positioned text"
 Set PosText.Left = 100
 Set PosText.Width = 80
 Set PosText.Justify = MTP_JFY_RIGHT
 Line.AddPosText( )
 ...

 

Created with the Personal Edition of HelpNDoc: Generate Kindle eBooks with ease