TE Edit Control Win32 / Win64 Help
Product page

TerMergePrint

Print a document without invoking the editing session.

BOOL TerMergePrint(prt)
HWND hWnd;Handle of the window to be accessed
struct StrPrint far *prt;Print request parameter structure.

Description: This function is used to print a buffer or a file to a specified printer or window device context and at a specified location on the page. If requested, this function can replace the field names with field data. The print parameter structure (StrPrint) is used to specify the printing parameters.

struct StrPrint {
char InputType;
char file[129];
HANDLE hBuffer;
long BufferLen;
char delim;
char padding1;
HDC hDC;
LPRECT rect;
long StartPos;
BOOL OnePage;
long NextPos;
LPBYTE MergeFields;
LPBYTE MergeData;
BOOL PrintHiddenText;
HANDLE hInst;
HWND hParentWnd;
int NextY;
HDC hMetaDC;
}

Member Variables:

InputType:This flag specifies the input type. If you wish to specify a disk file name, set the 'InputType' to 'F'. Conversely, if you wish to pass the text in a buffer, set this field to 'B'.
file:If the 'InputType' is 'F', specify the input file path name in this field.
hBuffer:If the 'InputType' is 'B', specify the global memory handle for the buffer containing the text.
BufferLen:If the 'InputType' is 'B', this field specifies the length of the buffer (hBuffer).
delim:If the 'InputType' is 'B', this field specifies the special character used to delimit the lines. This character can be a carraige-return (ASCII 13), or any other character of your choice. This field is not used when the buffer contains RTF data.
hDC:The device context of the printer or the window to print the text. The device context MUST be mapped to use the pixel units.

If this field is set to NULL, the editor opens a new device context to the current printer. If the 'hMetaDC' field is spcified (non-NULL), then hDC may not be NULL.

rect:This field contains a far pointer to a printing rectangle. The rectangle co-ordinates are specified in the millimeter (mm) units. For a heigher precision, you can specify the rectangle coordinates in twips units by specifying the negative values for the left, right, top and bottom variables in the rect structure.
StartPos:The positive value for this field specifies the character position to begin the printing. The negative value specifies the page number to begin printing. Set to 0 to begin the printing from the first page.
OnePage:Set this variable to TRUE to print one page only. When this variable is set to FALSE, the editor prints the entire document by spooling each page.
NextPos:(OUTPUT) The editor returns the character position of the next page to be printed. When the entire document is printed, the editor sets this field to 0.
MergeFields:This field specifies the pointer to a list of mail merge field names. Each field name must be separated by a '|' character. The list must be terminated by a NULL character. If you do not wish to merge field data, set this field to NULL.
MergeData:This field specifies the pointer to a list of mail merge data strings. Each data string must be separated by a '|' character. The number of data elements in the 'MergeData' array MUST be the same as the number of elements in the 'MergeFields' array. The list must be terminated by a NULL character. If you do not wish to merge field data, set this field to NULL.
PrintHiddenText:Set this field to TRUE to print any hidden text.
hInst:Pass the instance handle of your application using this field.
hParentWnd:Pass the window handle of your application using this field.
NextY:(OUTPUT) The field returns the Y pixel position on the device context after printing.
hMetaDC:This field is used to specify the metafile device context when printing to a metafile or when you need to specify different device contexts for attribute and data. In all other situations it should be set to NULL.

When a 'hMetaDC' is specified, then the editor uses the device context used in the 'hDC' field for only retrieving the device attributes. All text output is directed to the 'hMetaDC' device context.

When 'hMetaDC' specifies a metafile device context, the left and top coordinates in the 'rect' field must be set to zero.

Return Value: This function returns a TRUE value when successful.

Comment: The Visual Basic application should use the TerMergePrintVB function instead of TerMergePrint function.

You can set a print callback function (TerRegisterPrintCallback) to manipulate the document before the printing begins. This technique can also be used to print an HTML file using HTML Add-on.

Please note that this function is not available as an ActiveX control method. It must be used as a DLL function.